Skip navigation

Getting Started with Windows Phone 7 Development

Explore the general features to start building applications

Mobile phone development has exploded over the past few years, and with the release of Windows Phone 7 there's a new mobile platform available that offers an extremely productive way to build applications and games. With Windows Phone 7, you can build Silverlight or XNA applications and take advantage of languages and tools you already know. In fact, if you're already familiar with Silverlight (you do read my monthly column, right?), you can instantly be productive by building Windows Phone 7 applications with the same overall concepts.

The Windows Phone 7 platform can be grouped into four main categories, including runtime functionality (what you see on the phone screen); tools (the phone emulator, XNA Game Studio, Visual Studio, and Expression Blend); cloud services (e.g., location services, push notification services, and Xbox LIVE integration); and portal services (e.g., Windows Phone Marketplace) where consumers access applications. In this article, I'll introduce you to the Windows Phone 7 framework and runtime, discuss the tools that are available, and walk through several key features. Future articles will go into more detail and explain how controls, tasks, notifications, and other features can be used within mobile applications. Let's get started by taking a look at what Windows Phone 7 brings to the table for developers.

 

Windows Phone 7 Tools

Windows Phone 7 provides several benefits over existing mobile development platforms, especially when it comes to developer productivity. If you're just getting started building mobile applications for Windows Phone 7, the first thing you'll want to do is visit developer.windowsphone.com and download the free tools. If you already have Visual Studio 2010 or Expression Blend 4 installed, you can use them in conjunction with the Windows Phone 7 tools. If you don't have an IDE installed, the Windows Phone 7 tools include Visual Studio 2010 Express and Expression Blend for Windows Phone (both of which are free) that can be used to build applications.

The Windows Phone 7 tools provide everything you need, including the phone's Silverlight runtime, an emulator for testing applications locally (see Figure 1), samples, guidance documentation, and APIs to access different phone sensors and services. Although the tools are free, there is a yearly $99 fee to publish applications or games to Microsoft's App Hub so that users can search, try, and buy your applications. Visit create.msdn.com/en-us/home/membership for more details on how the App Hub membership works.

In addition to the Windows Phone 7 tools, there is also a robust set of resources available to help you learn how to build different types of applications and games. A set of Silverlight and XNA labs are available through the Windows Phone 7 Developer Training Kit. The documentation provides important details on best practices and user interface guidelines. Along with labs and guidance documents, Microsoft recently released a set of XAML templates that can be used to efficiently build mobile user interfaces. By using the templates, you can save a lot of time typically spent arranging text, controls and other objects in a Windows Phone 7 user interface. A list of these different resources is shown in Figure 2.

 

An Overview of the Windows Phone 7 Framework

The Windows Phone 7 framework consists of core phone system components, as well as Silverlight and XNA runtimes. I'll focus on Silverlight application development in this article, but the resources mentioned earlier will help get you started with XNA Game Studio if you're interested. Figure 3 gives an overview of the different runtime frameworks provided with Windows Phone 7.

Looking through the different Windows Phone 7 framework components shown in Figure 3, you can see that there's built-in support for sensors, navigation (PhoneApplicationFrame and PhoneApplicationPage), camera functionality, push notifications (for sending messages directly to a phone), media playback, Bing maps integration, and more. These features—combined with support for the Silverlight and XNA frameworks—provide robust functionality that can be used to build consumer or enterprise applications.

 

If you're a Silverlight developer, you may look through the framework components and wonder what version of Silverlight is available with the initial release of Windows Phone 7 and what features are supported on mobile phones. When Windows Phone 7 was being developed, Silverlight 3 had been finalized and Silverlight 4 was still in development. As a result, Windows Phone 7 supports Silverlight 3 plus additional functionality (some refer to the version as "Silverlight 3+"), such as custom phone controls, sensor APIs, launchers and choosers, hardware acceleration, and overall performance enhancements. Microsoft's developers also incorporated different optimizations into the Silverlight runtime provided with Windows Phone 7 to accommodate battery constraints and low-power processors. Features specific to Silverlight 4 aren't supported but I'm hoping they will be added quickly as new versions of Windows Phone 7 roll out. (Check out the list of supported framework features available in Windows Phone 7 here.)

What's really nice about the Windows Phone 7 framework is that if you already know XAML and C# (note that only C# is currently supported) you can build mobile applications very quickly without having to go through a new learning curve. Standard controls such as Button, TextBox, and TextBlock are available as well as new mobile-specific controls such as Panorama and Pivot. The learning curve comes into play with learning the new controls, using built-in system controls (e.g. ApplicationBar), and integrating with different launchers, choosers, or sensor APIs. If you have a good understanding of how object properties, methods, and events work, then it's simply a matter of spending a little time in the documentation and tutorials.

 

Key Windows Phone 7 Controls

Windows Phone 7 has a lot of important components that can't be covered in a single article. However, there are a few key concepts I'd like to discuss regarding controls. You've likely worked with most of the controls available in Windows Phone 7 since they're also available in Silverlight. However, there are a few controls that you need to know about, such as ApplicationBar, Pivot, and Panorama. Let's take a quick look at each of these controls and see how they can be used in mobile applications.

ApplicationBar. The ApplicationBar is a system control (as opposed to a built-in Silverlight control) used to provide direct access to commonly used functionality. Think of it like a toolbar that's always accessible in an application (see Figure 4 for an example). You can define an ApplicationBar using the XAML shown in Figure 5. The easiest way to work with the ApplicationBar control is to highlight the PhoneApplicationPage object in Expression Blend and then access the ApplicationBar property in the Properties window. From there you can visually add buttons and select from built-in icons, as opposed to manually typing the XAML code.

Pivot. In addition to the ApplicationBar system control, Windows Phone 7 also provides a Pivot control (which is a regular Silverlight control rather than a system control). The Pivot control is similar to the TabControl available in Silverlight applications since it can be used to display multiple data views or pages of data on a single screen. The Pivot control, as Figure 6 shows, is used to display email messages and contains three pivot items including all, unread, and urgent. The control has built-in gesture support capabilities that allow users to swipe the screen to switch between pivot items. Figure 7 shows an example of defining a Pivot control with two pivot items in it. When you create a new Silverlight Windows Phone 7 project in Visual Studio 2010 or Expression Blend you have the option of starting with a Pivot project.

Panorama. The final control that I'd like to introduce is the Panorama control. It's similar to the Pivot control in some ways since it allows data views to be accessed by swiping right or left on the screen. However, it's used to simulate one large horizontal screen that a user can navigate around, as Figure 8 shows. The screen can be divided into sections by defining multiple panorama items within the control.

Figure 9 shows an example of defining a Panorama control in XAML. As with the Pivot control, you can create a Panorama project in Visual Studio 2010 or Expression Blend which provides the necessary XAML to get started using the control quickly.

In addition to built-in controls such as Pivot and Panorama, Microsoft has also released additional controls in the Silverlight for Windows Phone Toolkit, available at silverlight.codeplex.com.

 

Launchers and Choosers

The final topic that I'll cover in this article is launchers and choosers available in Windows Phone 7. When developing an application, you may have the need to allow the user to launch another application in order to obtain pieces of data to use in your application. Launchers and choosers support this type of functionality while allowing applications to run in their own sandbox.

Launchers (located in the Microsoft.Phone.Tasks namespace) allow other applications to be launched from your application in situations where you don't expect data to be returned. An example would be the EmailComposeTask launcher which displays a new email message and allows the user to fill in the missing data and then send the message when they're done. Another example would be the PhoneCallTask which allows a phone number and display name to be passed directly to the phone. Other key launchers include SearchTask, SmsComposeTask, WebBrowserTask, and MediaPlayerLauncher. Figure 10 shows an example of using the EmailComposeTask to initiate an email message from within an application.

Choosers can be used to initiate a user dialog that returns data to your application asynchronously. Examples of choosers include CamerCaptureTask, EmailAddressChooserTask, PhoneNumberChooserTask, and PhotoChooserTask. As mentioned, choosers work asynchronously, meaning that you create them and provide a callback method that's invoked once the user finishes using a given chooser object. Figure 11 shows an example of using the EmailAddressChooserTask to select an email address from a user's contacts.

By using launchers and choosers, you can ensure that your application remains secure while allowing users to interact with other applications on their phones.

 

Stayed Tuned for More on Windows Phone 7

There are a lot more Windows Phone 7 topics that can be discussed, such as themes, push notifications, isolated storage, sensor APIs, the application life cycle and tomb stoning, etc. However, the goal of this article was to introduce you to the general features available in Windows Phone 7 and show a few examples of how they can be used to build applications. Future articles will drill-down into these features and provide additional details, so stay tuned!

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish