Chapter 1 - Introducing Windows Phone 7

Mobile computing has been growing in popularity over several years, while the mobile telephone has evolved into a ubiquitous device used by the majority of people today. The increasing capabilities of mobile phones, and the more universal coverage and higher bandwidth networks available to them, has meant that the combination of mobile computing and the phone has become a very persuasive and appealing platform for both consumer and enterprise applications.

Until relatively recently, people would have needed to carry around a personal digital assistant (PDA), a phone, a separate Global Positioning System (GPS) device, a pager or two-way text messaging device, and a digital camera. Now a single device provides all these capabilities and more, and at an affordable price.

It's now common to use a small mobile device to access phone services, music, video, Internet collaboration and information services, and communication systems such as email and messaging. Most modern smart phones and small form-factor devices have high resolution screens and advanced processing capabilities that support applications very similar to those more commonly seen on the desktop or in the domestic environment (such as MP3 players, TVs, and web browsers). Users can purchase and install applications from marketplace sites. In the future, corporations will also be able to distribute their own applications to selected users through private marketplaces.

Gg490768.note(en-us,PandP.10).gif Jana says:
Gg490768.personna-Jana-h50(en-us,PandP.10).pngUsing a phone as a comprehensive business tool is a perfect solution for mobile employees.

Developers are increasingly exposing their enterprise and corporate applications and services to mobile devices such as phones to establish an "access everywhere" paradigm for all kinds of working scenarios, where the difference between a fixed and a mobile device is mainly usability and the availability of more advanced application features (and, of course, limited by screen size and battery life). Consumers also are adapting to a world where the primary mobile information, socializing, and entertainment device is a phone. How ubiquitous this is, is evident from the number of people who no longer have a fixed phone line, and who rely on a mobile phone for all their communication requirements, both business and social.

A Standardized Platform

In the past, the programming and run-time environments on the phone were often quite different from the almost universal model supported for the server, desktop, and laptop. Even where the development environments were similar (such as on the Microsoft® platform, where the ability to develop mobile applications using Microsoft Visual Studio®, Visual C++®, or Visual C# were similar), the wide range of screen resolutions, device capabilities, hardware nuances, and other incompatibilities made writing mobile applications a challenge. This tended to limit development of enterprise applications in the mobile device area.

However, with the advent of the typical form factor and design of consumer-oriented mobile devices, such as iPhone and Android-powered phones, it is possible for the programming model, code languages, run-time environment, and display technologies to converge so that the ideal of "write once, run everywhere" (though usually on only a specific manufacturer's device) is slowly becoming a reality. A common design and set of capabilities means that it is much easier for developers to create applications that work well on that device, even if they are not directly portable to devices from other manufacturers.

Windows Phone 7 brings all the advantages of a standardized platform and a consistent developer experience to the Microsoft platform for devices from many different manufacturers. It is not a replacement for Windows Mobile, which continues to provide a powerful platform for a wide range of devices and application scenarios. Instead, Windows Phone 7 is a brand new mobile device that incorporates a comprehensive set of features necessary to build applications that satisfy the needs of business and consumers, to allow developers to easily create powerful interactive and attractive applications, and to reuse their skills and knowledge of existing modern development environments, such as the Microsoft Silverlight® and the Microsoft XNA® development platforms.

Gg490768.note(en-us,PandP.10).gif Christine says:
Gg490768.personna-Christine-h50(en-us,PandP.10).pngWindows Phone 7 provides a standardized platform that simplifies both design and development of applications that run on devices from multiple phone manufacturers.

Windows Phone 7 incorporates the majority of features that users now expect to find on a mobile device, such as cloud service and media integration, easy and safe application installation, a stylish modern user interface (UI) that supports gestures and smooth animation, and device capabilities, such as location awareness, camera, sound recording, messaging, and multi-touch. Figure 1 shows the main features of a Windows Phone 7 device.


Figure 1

The features available on Windows Phone 7 devices

Windows Phone 7 is also an integrated part of the end-to-end application development and run-time story at Microsoft. The wide range of powerful Microsoft frameworks, applications, and services work with Windows Phone 7 to provide a consistent and complete environment for developing enterprise applications that extend the corporate presence to mobile workers, as well as to consumers.

In addition to integration with applications such as Microsoft Exchange, Windows Live® network of internet services, and Microsoft SharePoint® team services, developers can easily take advantage of reliable and scalable custom services that run in the cloud on the Windows Azure™ technology platform. Windows Phone 7 also uses services specifically designed to integrate with the device, such as the Location Service and Notifications Service provided by Microsoft, and it is likely that more of these types of services will appear in the future.

Windows Phone 7 also allows developers to easily distribute and sell their applications using a combination of the developer portal and the Windows Marketplace portal. Windows Marketplace provides a single consistent environment for users to obtain applications with the knowledge that they have been certified for use on the device and will properly integrate with it. In conjunction with the targeted advertisement opportunities available through the Microsoft Advertising Exchange for Mobile hub, this also allows developers to profit from creating Windows Phone 7 applications.

Data-driven Applications

Although a few simple applications may run wholly on the device without accessing remote services, almost all data-driven applications for both the enterprise and consumer market will connect to a remote system to obtain and upload data. A growing trend is to expose these data services from a cloud-based host, which provides resilience, performance, lower cost, elasticity to meet varying demand, and the possibility of global reach through multiple geographically separated installations of the service. In particular, because phones are relatively low-powered devices with limited facility for local data storage, using a remote or cloud service to drive the application can provide an experience comparable to far more powerful types of client devices.

Gg490768.note(en-us,PandP.10).gif Christine says:
Gg490768.personna-Christine-h50(en-us,PandP.10).pngData-driven applications for enterprise and consumer markets will need to connect to remote systems that expose the data they require.

Whereas in the past, most data was communicated using multiple proprietary formats, the common approach today is to use standard protocols and standard communication architecture styles, which allows developers to mix and match services more freely; in addition, it reduces dependencies between the device and the data service. The programming and run-time environments available on most modern mobile devices support these formats or provide tools and frameworks that make it easy to consume them.

The result of this remote service integration is a very persuasive scenario that allows mobile devices and their users to take advantage of a huge number of services. Examples range from social networking and location-aware services, to productivity applications such as office-style applications and information search, to enterprise messaging and line-of-business (LOB) applications.

Developing for the Windows Phone 7 Platform

The Microsoft Windows Phone 7 provides a platform for mobile computing on the phone. It has been designed to make programming applications, and sharing and reusing code, much easier by taking advantage of two common technologies that already have a comprehensive user base: Silverlight and XNA:

  • Silverlight. This is derived from the Windows Presentation Foundation (WPF) technology. WPF uses Extensible Application Markup Language (XAML) to define the UI and code that uses the .NET Framework classes to implement the functionality of the application. Silverlight uses a reduced set of both WPF and the .NET Framework. It was designed to provide a lightweight, compelling, attractive, and interactive UI; and broad capabilities that take maximum advantage of the features of the device. It can be delivered to a Web browser and executed in a hosted control; or, like with Windows Phone 7, it can be packaged as a XAP file and run natively on devices that support it. Silverlight provides a development environment that is ideal for business applications and consumer applications that display, collect, and process information. For more information about Silverlight, see
    The implementation of Silverlight used in Windows Phone 7 is a subset of the full Silverlight functionality, with the addition of some phone-specific APIs. For more details, see "Differences Between Silverlight on Windows and Windows Phone" on MSDN® (

  • XNA. This is composed of software, services, resources, and communities that focus on enabling developers of games and media-rich applications to be successful on Microsoft gaming platforms. These include the XNA Game Studio Express, the Microsoft DirectX® application programming interface display mechanism, and other XNA gaming tools and technologies; as well as tutorials, white papers, samples, and more. XNA gives developers the capability to directly access features of the device such as the video and sound systems, where this is necessary to provide the performance required for highly interactive gaming and associated types of applications. For more information about XNA, see the XNA developer portal site at
    The implementation of XNA used in Windows Phone 7 is a subset of the full XNA functionality. For more information, see "XNA Framework and Silverlight" on MSDN at (

For more information about the differences between Silverlight and XNA and about how you can use XNA framework routines from a Silverlight application, see Appendix B, "Silverlight and XNA in Windows Phone 7."

To enable a consistent application platform, all Windows Phone 7 devices implement at least a minimum set of hardware and software features that provide an acceptable and consistent user experience across devices from different manufacturers. This simplifies development by allowing the application to run on any certified Windows Phone 7 device without the developer worrying about whether there is sufficient memory, how touch and orientation are supported, or whether additional features such as a camera or GPS are available.

Gg490768.note(en-us,PandP.10).gif Christine says:
Gg490768.personna-Christine-h50(en-us,PandP.10).pngEvery Windows Phone 7 phone is guaranteed to have a powerful graphics processor unit (GPU), GPS and wireless-driven location capabilities, an accelerometer, an 800 × 480 resolution multi-touch screen, a camera, a microphone, support for "push" notifications, an FM radio, and—of course—phone and text messaging capabilities.

Chapter 2, "Designing Applications for Windows Phone 7," describes the development platform provided by Windows Phone 7 in more detail and discusses the factors you must keep in mind when designing applications for the phone.

In addition, the enforced distribution and certification of third-party applications through Windows Marketplace ensures that the downloaded software meets a set of acceptable minimum criteria for quality and compatibility to give a consistent user experience. Chapter 7, "Interacting with Windows Marketplace," provides information about how you can submit your applications to Windows Marketplace for distribution to end users.

Resources for Developers

The primary tool for developing Windows Phone 7 applications is the familiar Visual Studio. Debugging, coding, testing, and so on, can all be performed from within the integrated development environment (IDE), just as you would in any other Microsoft-based application development scenario. The Windows Phone Developer Tools that you can download and install include a phone emulator that allows you to develop applications without having a physical phone, although you should test your application on a real physical device before you deploy it.

Gg490768.note(en-us,PandP.10).gif Callout:
Windows Phone development uses the .NET Framework and tools such as Visual Studio that most developers are already familiar with.

The emulator is a virtual machine that runs a copy of the actual phone operating system, so it is an accurate simulation of the real phone runtime in all respects except for performance (the emulator will generally perform more slowly than a real device) and sensor availability (for example, location and acceleration emulation are not provided by the phone emulator).

Gg490768.note(en-us,PandP.10).gif Markus says:
Gg490768.personna-Markus-h50(en-us,PandP.10).pngThe emulator is very close to the real phone, but it is a good practice to test against a real device.

Developing for Windows Phone is essentially the same as developing against the .NET Framework using the Silverlight and/or XNA libraries, although you can use only the C# .NET language to create your applications in the release version (Microsoft Visual Basic® will be supported in an upcoming release). The phone runtime includes specific libraries that provide access to capabilities such as sensors, location services, media capabilities, messaging services, the camera, and Windows Marketplace.

Gg490768.note(en-us,PandP.10).gif Christine says:
Gg490768.personna-Christine-h50(en-us,PandP.10).pngSilverlight for the phone is a subset of Silverlight 3.5 plus APIs for phone-specific capabilities.

Resources for Silverlight Developers

To develop Silverlight applications for Windows Phone 7, you can use Visual Studio 2010, Visual Studio 2010 Express Edition, and the developer tools available for download from Microsoft. The main tool set is the Windows Phone Developer Tools, which includes specially adapted versions of Visual Studio 2010 Express Edition and Expression Blend® design software 4.0 (for developing the UI), integration components and templates for Visual Studio 2010 (which you can use instead of installing Visual Studio 2010 Express Edition), Silverlight tools, run-time debugging support, and an emulator for Windows Phone 7. You can obtain the Windows Phone Developer from the Windows Phone and Xbox 360® App Hub at

You will also need to install the Windows Phone Developer Tools October 2010 Update from

For a simple walkthrough that shows how you can get started building Silverlight applications, see "How to: Create Your First Silverlight Application for Windows Phone" on MSDN ( A series of videos that describe development of Windows Phone 7 applications, for both Silverlight and XNA, is available from "Windows Phone 7 Jump Start Training" on the Windows Phone Developer Blog (

For information and guidelines about the style recommended for Silverlight applications, see Windows Phone UI Design and Interaction Guide (a PDF document) available from the Microsoft Download Center (

Appendix A of this guide, "Tools, Frameworks, and Processes," also contains information to help you get started developing Silverlight applications for Windows Phone 7.

Resources for XNA-Based Application Developers

This guidance concentrates on applications built using Silverlight. However, there are many resources available for developers who use XNA to build applications. The Windows Phone Developer Tools include XNA Game Studio, which developers can use to create XNA applications. For information about Game Studio, see "XNA Game Studio 4.0" on MSDN (

For a simple walkthrough that demonstrates how to create XNA applications, see "How to: Create Your First XNA Framework Application for Windows Phone" on MSDN ( For a series of videos that describe development of Windows Phone 7 applications, see "Windows Phone 7 Jump Start Training" in the Windows Phone Developer Blog (; the videos include coverage of XNA application development. For more useful information about XNA development, see XNA Creators Club Online on the Microsoft App Hub website (

Resources for Web and Service Developers

Windows Phone 7 includes comprehensive web browsing capabilities. In addition, ASP.NET allows you to detect the client device type making a request so that you can provide the content in a format and style appropriate to the device. For information about how Windows Phone 7 supports web browsing, and how to maximize your application experiences on Windows Phone 7, see Designing Web Sites for Phone Browsers (a PDF document) available from the Microsoft Download Center (

For information about mobile device support in ASP.NET, see "ASP.NET for Mobiles" on the Microsoft ASP.NET website ( and "Walkthrough: Adding Support for Devices" on MSDN (

Mobile phone applications aimed at the enterprise and for consumer use will usually require access to remote services to be able to obtain information, exchange data, or synchronize content. Typically, on the Microsoft platform, you will implement these services using the Windows Communication Foundation (WCF) technology that is part of the .NET Framework. For information about WCF, see "Windows Communication Foundation" on MSDN (

A common approach for delivering data or exposing services to mobile devices such as Windows Phone 7 is by using the Representational State Transfer (REST) architectural style for the service. For information about REST-based services, see "REST in Windows Communication Foundation (WCF)" on MSDN ( and "An Introduction To RESTful Services With WCF" in MSDN Magazine ( For a definition of the way that REST-based services work, see "Canonical REST Entity Service" on the Microsoft .NET website (

In other cases, such as exchanging small volumes of data between the client and server or calling specific methods on the server, you may decide to use SOAP instead. For more information about WCF, see "Getting Started with WCF" on MSDN (


The following list describes the technologies, patterns, frameworks, applications, and other terms commonly associated with developing for mobile devices such as Windows Phone 7:

  • Accelerometer. A device capability that measures acceleration in three planes, and the direction of the force of gravity that indicates the attitude of the device. Can be used to detect movement, including gestures such as shaking the device.
  • Advanced Encryption Standard (AES). A symmetric encryption algorithm available on Windows Phone 7 that can be used to encrypt data.
  • AllKeys API. Allows your programs to request that all key presses be sent directly to the requesting application. Usually, some buttons are intercepted by the operating system for its own use, but games and input-intensive applications may want access to these buttons for their own use.
  • Application bar. The small area at the bottom of the screen that contains buttons for commonly used functions of the currently executing application. This optional bar shows a set of icons by default, but the user can expand it to also show the text captions for the buttons. An application can show a maximum of four buttons on the application bar.
  • Application Verifier (AppVerifier). A software test tool used to check the stability of the application and detect common programming mistakes associated with memory management. AppVerifier can detect and pinpoint memory leaks, handle leaks, and heap corruption.
  • Atom Publishing Protocol (Atom Pub). An XML-based format for data that uses a Representational State Transfer (REST) architectural style where the names of collections and entities are defined in the query string of a request.
  • Cloud services. Services that run in one or more remote data centers on specially designed hardware and a virtual runtime (fabric) that provides very high availability, reliability through multiple instances, performance, and scalability. Generally, cloud services are cost-effective ways to provide local and global access to applications and services without requiring the investment, expertise, maintenance, administrative overhead, and run-time cost of an on-premises server infrastructure.
  • DPI. Dots-per-inch (DPI) is a measure of video dot density, in particular the number of individual dots that can be placed within the span of one linear inch (2.54 cm.). It is related to image resolution.
  • Elasticity. The capability of a service, such as a cloud-based application, to be expanded by adding service instances and shrunk by removing service instances to more closely match the current requirements and load. This minimizes cost by not requiring the acquisition of sufficient hardware, software, and bandwidth to satisfy peak demand that is then idle at other times.
  • File-based applications. File-based applications store data in a file and often work as editors for specific file formats. Examples include word-processors and spreadsheet applications.
  • GAPI. Game API (GAPI functions) provides solutions for developers who want to write high-performance, real-time games on devices running on Windows Mobile-based devices.
    GAPI was deprecated in Windows Mobile 6.5, so developers should use the AllKeys, DirectDraw, and Direct3D® Mobile APIs instead.

  • GPS. See "Location service."
  • Hash-based Message Authentication Code (HMAC). A keyed hash algorithm that can be used to create a non-reversible hash value for data. Two versions that use a Secure Hash Algorithm (SHA) are available on Windows Phone 7: HMACSHA1 and HMACSHA256.
  • Home screen. The point from which users start most of their applications, and the point that the user can return to with a press of the Home button. In Windows Phone 7, developers can customize the Home screen by providing tile images that the user can add to the page.
  • Ink Presenter control. A primitive control that can display strokes within a Canvas control.
  • Location service. A phone-based service that the phone uses to discover its geographical location based on a series of factors. These factors can include the built-in GPS capability, and triangulation of public Wi-Fi networks and phone signal towers.
  • Managed code. Managed code is code compiled for the .NET Framework. Managed code is often written in Visual C# or Visual Basic .NET.
  • Metro theme. The standard theme used in Windows Phone 7, and recommended for applications you develop so that they integrate seamlessly with the operating system and other applications. The theme is designed to provide a modern UI that is easy to use, while minimizing power consumption on the phone.
  • Microsoft Push Notification System (MPNS). A service that allows developers to send notifications to users' phones that are displayed even if the application is not running, or will update a tile on the Start menu of the phone to indicate that new information is available.
  • Model-View-ViewModel (MVVM). A design pattern particularly suited to Windows Presentation Foundation (WPF) and Silverlight applications. It uses views to implement the UI, a model that holds the data for the application, and view models that access the model and populate the views using the powerful data-binding capabilities of WPF and Silverlight. It makes it easier to decouple sections of the application, develop the components, test them, and maintain the application post deployment.
  • MultiScale Image control. A control that can be used to display a very large image without requiring it to be fully downloaded to memory. It uses a collection of multiple sub-images at different resolutions. The control provides methods to pan and zoom over the image.
  • Non file-based application. An application that does not need to store any data in a file. For example, a calculator application.
  • Notifications. Messages that are sent from a server to the phone through the Windows Notification Service and can be received even when the application is not running. Notifications can display a message at the top of the screen or change a program tile on the Home screen. It is also possible to send raw notifications that the application itself must handle. Users must register to receive notifications on their phone.
  • Open Data Protocol (OData). A web protocol for querying and updating data. OData builds on web technologies such as HTTP (, Atom Pub, and JavaScript Object Notation (JSON to provide access to information from a variety of applications, services, and stores.
  • Panorama control. A control that offers a way to view controls, data, and services by using a long horizontal canvas that extends beyond the confines of the screen. Areas of this canvas are viewed as smaller individual areas by panning sideways. Effectively, it provides a viewport over the larger area. The user can scroll the window horizontally across the larger view to see the complete content.
  • Pivot control. A control that provides individual views over related sets of data. Typically, the individual views are related; for example, views that show new items, favorite items, and recently viewed items from the users stored photos. This control can be used to present filtered views of large data sets or to switch between application views. The user pans horizontally to navigate between the views.
  • Prism. A free utility library from the Microsoft patterns & practices group. The components in this library can help developers build applications for WPF, Silverlight, and Windows Phone that are easier to maintain and update as requirements change.
  • Proximity sensor. A device capability that detects whether the phone is close to an object, such as the human body. The operating system uses this to change the behavior when the device is used in phone mode.
  • Push notifications. See "Notifications."
  • Representational State Transfer (REST). An architectural style used to expose data from services that allows simple access to, and optional manipulation of, information without requiring the server to maintain state between requests.
  • Rfc2898DeriveBytes. An algorithm available on Windows Phone 7 that takes a password, a salt, and an iteration count, and then generates encrypted keys of virtually unlimited length.
  • Secure Hash Algorithm (SHA). An algorithm for creating a non-reversible hash value for data. Two versions are available on Windows Phone 7: SHA1 and SHA256.
  • Simple Object Access Protocol (SOAP). A protocol used to allow clients to execute methods on a remote server to obtain information or perform processing. It is an XML-based format that packages the data in a SOAP envelope. SOAP messages carry both payload and metadata, which provides for transport-independent security and reliability and can add layers of functionality to the communication, such as atomic transactions or cross-system activity tracing.
  • Soft input panel. An on-screen input method (software keyboard) for devices that do not include a hardware keyboard.
  • SQL Azure. A solution that offers multiple highly reliable, scalable, cloud-based relational databases where you can store data used by your services and applications. Databases are provisioned on-demand and are charged according to usage. SQL Azure is part of the Windows Azure platform.
  • Secure Sockets Layer (SSL). A cryptographic protocol for securing communication between clients and services over a TCP/IP network. Often described as HTTPS, it operates by default through port 443 instead of port 80. The more recent implementation is Transport Layer Security (TLS).
  • Transport Layer Security (TLS). A cryptographic protocol for securing communication between clients and services over a TCP/IP network. Provides better overall security than SSL, and is often used to secure messaging communication as well as web requests and responses.
  • Tombstoning. The process whereby the currently executing application must stop to allow another application or device feature (such as an incoming phone call) to execute. The application must save its state so that it can either be continued from where it left off or be terminated without losing data.
  • Touch input. Windows Phone 7 supports touch and gestures for interaction with the phone and applications running on it. It recognizes up to four touch points and gestures such as tap, double-tap, pan, flick, pinch, stretch, and touch hold.
  • Windows Azure. A highly reliable, scalable, cost-effective, and elastic run-time environment within the cloud that you can use to run applications that expose services or accept web requests.
  • Windows Azure Web Role. An instance of a web service running within Windows Azure that accepts connections from clients and returns responses to them while performing some processing that is appropriate to the Windows Azure service that hosts the role.
  • Windows Azure Worker Role. An instance of an application service running within Windows Azure. Worker roles run asynchronously and communicate with web roles through queues or messages; generally to perform background tasks or other processing that is not part of the web role.
  • Windows Marketplace. Delivers an end-to-end solution for end-users to discover, purchase, and download Windows-based applications for the desktop and mobile devices. This includes an end-user experience on the device, a website, as well as a self-service portal for developers to submit their applications for listing in Windows Marketplace.
  • Windows Mobile Device Center. An application that you can use together with Windows Vista® operating system or Windows 7. It offers device management features and lets you synchronize data between a Windows Mobile-based device and a computer. Windows Mobile Device Center replaces ActiveSync® technology, which was available on earlier desktop operating systems.
  • Zune Desktop Client. A desktop synchronization application that is primarily used by consumers for synchronizing music and videos, but it is also used by developers to upload applications to the phone during the development and testing processes.

More Information

For a comprehensive overview of the Windows Phone platform and how it is designed to support many different types of application, see the video presentation "Overview of the Windows Phone 7 Series Application Platform" on the MIX website (

To see a more detailed description of the underlying mechanisms and architecture of the Windows Phone 7 operating system and how you can interact with services, see the video presentation "Windows Phone Application Platform Architecture" on the MIX website (

Microsoft provides a portal for developers to help them get started writing applications for Windows Phone 7. This includes information about the operating system and the device capabilities, developer resources, forums, tools for working with Windows Phone 7, and access to a market place for selling and distributing applications. You can find this portal on the Microsoft App Hub website (

In addition, the MSDN site includes full documentation for developing for Windows Phone 7. See "Windows Phone Development" (

A useful frequently asked questions (FAQ) for getting started with Windows Phone 7 is available on the Microsoft Windows Phone forum (

General information about the Windows Phone 7 platform is available from "Application Platform Overview for Windows Phone" on MSDN (

Blogs, Code Samples, Training Kits, and Windows Marketplace

Additional documentation and code samples are available to help you learn about both Silverlight and XNA on Windows Phone 7. See the following resources:

These and all links in this book are accessible from the book's online bibliography. The URL to the bibliography can be found in the preface, in the final section, entitled, "Where to Go for More Information."