Silverlight for Windows Phone 7

The NDA on Silverlight for Windows Phone 7 has been lifted for a few months now, but I've been too busy working to get it into a finished product to blog about it previously.  But now I hope to spend a few minutes each day sharing some tips and tricks of developing Windows Phone 7 applications.

As you probably already know, Silverlight is the application platform for Windows Phone 7.  With the combination of Silverlight, the XNA framework, Visual Studio, Expression Blend and Windows Phone Marketplace, developers have the richest, most productive development tools and platform for creating and deploying high performance, compelling phone applications.  The development tools are free and available for download - download them at https://developer.windowsphone.com/, or more specifically at the download link at https://www.microsoft.com/downloads/details.aspx?FamilyID=c8496c2a-54d9-4b11-9491-a1bfaf32f2e3&displaylang=en

 

To get started:

1. Install the development tools from the link above

2. Once you have the development tools installed, start Visual Studio 2010. 

3. Create a new project with the Windows Phone Application template.  When the new project has loaded, you'll see a design surface populated with an image of a phone. 

4. If you want, click on the Toolbox to show the available Windows Phone Controls, and drag some controls onto the design surface.  Customize the design as you like.  To attach a Click event handler to a Button, simply double-click on the Button on the design surface; this will bring you to the code page.  Click on the tab "MainPage.xaml" to go back to the design page.  For more event handlers, click on the Events tab on the Properties window on the bottom right.

5. Click on the Start Debugging button (shortcut key is F5) to build and run it.  You'll see the Windows Phone Emulator launch and boot up (this may take a couple of minutes the first time). Once it's booted up, your application will be deployed on the emulator and ready for use. 

- If you have a Windows Phone 7, connect it to your PC and change the target to "Windows Phone 7 Device", then click on Start Debugging to deploy your application to your phone.

So as you can see, it is really easy to get started and become comfortable with the development of Windows Phone 7 applications. 

 

Silverlight for Windows Phone 7 is mainly Silverlight 3 with some Silverlight 4 capabilities and some improvements that are specific to the phone.  In particular, these are some of the most obvious differences for the phone:

1.  SupportedOrientations - This determines if the application runs in Portrait or Landscape mode, or both PortraitOrLandscape.  If set to PortraitOrLandscape, you can click on the rotate clockwise or rotate counter-clockwise buttons on the Windows Phone Emulator to simulator the user rotating the phone to see how the application looks like in a different mode. 

2. Orientation - Indicates if the orientation of the phone is portrait or landscape.  You can bind to this property for differentiating layout when in portrait and landscape.

3. SystemTray.IsVisible - Indicates if you want the SystemTray to be displayed when your application is running.

4. Application model - This is a whole topic on its own, which I'll write about tomorrow.  If you're porting existing Silverlight applications, you'll notice that MainPage inherits from PhoneApplicationPage.  In the Solution Explorer, under the Properties folder, there is a file WMAppManifest.xml that specifies NavigationPage that is the startup page.  You can change this value to change the startup page.

 

If you're new to developing Windows Phone 7 applications, I hope this helps you get started on the exciting path to building rich phone applications, and I'll be adding more tips and tricks.  If you're an advanced Windows Phone 7 programmer, I'll be writing about some of the newly added fixes and features for better experiences.