This book is a hands-on guide to building mobile applications for Windows Phone 7.5 using Silverlight, C#, XNA, or HTML5. The Windows Phone 7 operating system is Microsofts latest entry into the fiercely competitive mobile market. Windows Phone 7 is not an upgrade of previous mobile operating systems, Windows Mobile and Windows Phone 6.5. Microsoft has reimagined what a mobile operating system should be and completely changed the rules on how to build mobile applications.
To power the phone, Microsoft started with familiar foundations in Windows CE the .NET Compact Framework, and the Zune user interface, adapted the Silverlight and XNA libraries, and then added entirely new APIs for interacting with mobile hardware, sensors, and software. In this book we show you how to build user interfaces that adhere to the new Metro design, and how to use the new APIs to access the sensors and integrate with the built-in application.
This book is written for C# and .NET developers who are familiar with XAML, Silverlight or WPF development. This book does not teach you the subtleties of C# or Silverlight/XAML development. That being said, the book avoids many of the more powerful features of Silverlight and the Model-View-ViewModel pattern used by many Silverlight developers. Instead we kept the focus on the features and APIs that are unique to the phone and endeavored to make the content accessible to those readers who are not very familiar with Microsoft technologies.
This book has four parts, fifteen chapters, and three appendices. We divided the book into sections that introduce Windows Phone 7, cover the core concepts of the phone, and discuss enhancements to Silverlight. The final section of the book shows you how Silverlight applications can use the powerful graphics API found in the XNA Framework.
Part 1 is an introduction to Windows Phone, the developments, and the SDK. This part walks you through creating your first application.
In chapter 1, youll discover why Microsoft scrapped the Windows Mobile operating system in favor of a completely new smartphone platform. We compare Windows Phone 7 to Android and iOS development and introduce you to Visual Studio and the SDK tools youll use when building applications.
In chapter 2 youll build your first Windows Phone 7 project which is a traditional Hello World application. We use the Hello World application to introduce you to touch events, application tiles, the application bar, and the Windows Phone navigation model.
Part 2 examines the core Windows Phone platform and what makes developing for the phone different from developing for the desktop or the browser. Well introduce concepts that are brand new to Windows Phone, as well as concepts that have been adapted to operate within the phones limitations.
In chapter 3 youll learn about Fast Application Switching, Microsofts name for the battery-saving technology that allows a dormant application to be quickly restored when a user switches from a foreground application to a background application. Youll also learn how to create background agents that run periodically.
In chapter 4 youll read about how to use Launchers and Choosers to interact with built-in applications such as the phone dialer, email, and the People Hub.
In chapter 5 youll store application data using isolated storage and a SQL database.
In chapter 6 youll build an application that captures images from the phone camera and allows a user to make simple modifications to the photographs.
In chapter 7 youll integrate an application with the built-in Pictures and Music + Video Hubs.
In chapter 8 youll learn how to obtain data from the phones hardware including the accelerometer, compass, gyroscope, and motion sensor.
In chapter 9 we cover networking topics such as using TCP sockets and Push Notifications. Push Notifications provide the ability for an external application or web service to send messages and updates to a particular Windows Phone device.
Part 3 presents new Silverlight features and controls used to build applications that match the look and feel of Windows Phone.
In chapter 10 youll take a deep dive into the Application Bar, Panorama, and Pivot controls that are unique to the Windows Phone.
In chapter 11 youll learn how to build applications that automatically adjust themselves to match the Metro design, and how to control the software keyboard. You will also be introduced to the Silverlight Toolkit for Windows Phone, a Codeplex project from Microsoft.
In chapter 12 youll work with the MediaElement to play audio and video and will learn how to create a Windows Phone 7 Smooth Streaming client application.
In chapter 13 youll build a location-aware application using location services and the Bing Maps API. Youll also build an HTML5-based application.
Part 4 of this book demonstrates how Silverlight and the XNA Framework can be used together to build exciting games and applications. The XNA Framework includes a rich library for three-dimensional modeling and rendering.
In chapter 14 youll use the Windows Phone Silverlight and XNA Application template to create a Hello World game, and learn the techniques used to render Silverlight user interface elements with the XNA graphics framework. We give you a crash course in XNA concepts such as 3D animation techniques, collision detection, and the game loop.
In chapter 15 youll continue working with the sample game and learn how to use sprites for 2D graphics and animation. Youll use raw touches, gestures, the motion sensor, and the Mouse API to let a game player wander around the game world.
All source code in the book is in a fixed-width font like this, which sets it off from the surrounding text. In many listings, the code is annotated to point out the key concepts, and numbered bullets are used in the text to provide additional information about the code. Weve tried to format the code so that it fits within the available page space in the book by adding line breaks and using indentation carefully. Sometimes, however, very long lines include line continuation markers.
The source code presented in the book can be downloaded from the publishers web site at www.manning.com/WindowsPhone7inAction.
The source code is organized into folders for each chapter, with sub-folders for each project. The source code contains the completed sample projects for each chapter. Many of the sample projects link to image files shipped as part of the SDK. We chose not to redistribute the image files and instead used Visual Studios linked file features when adding the images to the projects.
The Windows Phone Developer Tools, which Microsoft provides as a free download, are required to compile and execute the sample projects presented in this book. The Windows Phone Developer Tools install an express edition of Visual Studio 2010 configured with the phone development tools. If you already have a retail edition of Visual Studio 2010 installed on your computer, the phone development tools will be installed as a plug-in to the IDE. Windows Phone projects can be written in both C# and Visual Basic.
Well use the express edition throughout the book for the screen shots and sample code. Code and user interface design features will work the same in the retail editions of Visual Studio 2010. You can download the Windows Phone Developer Tools from http://create.msdn.com.
A physical Windows Phone is not required. The Windows Phone Developer Tools include the Windows Phone 7 Emulator. With a few exceptions, the samples in this book will run in the emulator exactly as they would on a physical phone. The samples that integrate with the Music + Videos Hub and the samples that make use of the compass and gyroscope will require a physical device. If you want to use a physical device, a $99 yearly membership to the App Hub is required to unlock your phone.
The Windows Phone 7 Emulator should work on most recent computers. The emulator performs better if your computer has a CPU with virtualization extensions like most of the recent AMD and Intel CPUs. The emulator works best with a DirectX 10 or later graphics card with a WDDM 1.1 driver. The system requirements for the Windows Phone tools are
Purchase of Windows Phone 7 in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/WindowsPhone7inAction. This page provides information on how to get on the forum once youre registered, what kind of help is available, and the rules of conduct on the forum.
Mannings commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the author can take place. Its not a commitment to any specific amount of participation on the part of the author, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!
The Author Online forum and the archives of previous discussions will be accessible from the publishers website as long as the book is in print.