App Development for Windows Phone 7 101
Join the DZone community and get the full member experience.Join For Free
Application development for the Windows Phone 7 is accomplished through the help of the Microsoft .NET application programming interface (API). The .NET development platform supports multiple languages and executes from within a common language runtime environment. Two different frameworks can be used to develop apps. One is the Silverlight application framework and the other is the XNA framework.
Microsoft Silverlight is a browser-diagnostic development platform built on the .NET framework that utilizes a variety of technologies that support a multitude of programming languages. Microsoft Visual Studio is the primary application used in the Silverlight platform and it is also shared with the XNA development platform.
The XNA development platform is a development framework that utilizes XNA Game Studio. XNA Game Studio is a managed-code class library designed specifically for game development. Its advantages are an easier learning curve with a free toolset. Apps using XNA Game Studio are playable on a variety of gaming platforms, including Windows Phone 7.
The first step in developing apps for the Windows Phone 7 is to setup the proper development environment. At a minimum, Windows 7 or Vista and a DirectX 10 compatible graphics card are required. Go to http://create.msdn.com/en-us/home/getting_started and follow the instructions to install all the free development tools. These include:
- Visual Studio 2010 Express
- Windows Phone Emulator
- XNA Game Studio 4.0
- Microsoft Expression Blend for Windows Phone
- .NET Framework 4
To begin creating your first app, perform the following steps:
1) Open Visual Studio 2010 Express. This may take a few minutes, if this is the first time Visual Studio has been run. It will initialize various settings. When this process is complete, Visual Studio displays a startup page that lists a variety of information.
2) Click the “New Project” link from the menu bar on the left side of the GUI. The New Project screen displays a variety of templates.
3) Click “Windows Phone Application” from the list of templates. The template name appears highlighted.
4) Enter a project name in the “Name” field towards the bottom of the GUI.
5) Enter a name in the “Solution Name” field towards the bottom of the GUI.
6) Click the “Create directory for solution” check box above the OK button. This assists in organizing your project.
7) Click the OK button. The new project is created.
After the project is created, Visual Studio loads and displays the contents of a file called MainPage.xaml. The GUI is in design mode with the left pane showing how your application will look on the Windows 7 phone and the right pane showing the code. At any time you can press CTRL+F5 to compile the current code and run it in the Windows Phone Emulator. While developing, any changes entered on the right development pane will display on the left pane.
At this point, you’re ready to begin app development using the Visual Studio editor. Visual Studio provides an effective platform to develop code and there are a number of online resources available as well as WP7 Help hosting companies to assist during the development process. Here are a few that are worth bookmarking:
The App Hub website is an excellent resource for Windows Phone 7 development with lots of tips and downloads just a mouse click away. http://create.msdn.com/en-US/
The Windows Phone Developer Blog is also an excellent site for information.
Programming in the XNA framework requires the same minimum graphics requirements as programming in Visual Studio. The XNA Wiki (http://www.xnawiki.com/index.php?title=Graphics_card_compatibility ) contains a list of graphics cards that are compatible with XNA Game Studio.
The following steps describe how to begin programming in the XNA framework.
1) Ensure Microsoft Visual Studio is installed, as explained earlier.
2) Install the latest version of Microsoft XNA Game Studio. Only install this application from the Microsoft website. Some mirror sites offer compromised builds. Play it safe and always download the installation directly from Microsoft. XNA Game Studio 4.0 is available at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9ac86eca-206f-4274-97f2-ef6c8b1f478f
3) Start the Visual Studio application.
4) Click “File” and select “New Project”. A dialog box lists various tree nodes, each represent a project type.
5) Select the “XNA Game Studio” tree node. This is located under the “Visual C#” node. A list of projects displays in the right pane.
6) Select “Windows Game” in the right pane.
7) Enter a project name in the “Name” field on the lower portion of the GUI.
8) Enter the directory path in the “Location” field. This defines where the new project will be created.
9) Click the OK button. The new project is created and the GUI switches to code entry mode.
You are now ready to begin developing your game within the XNA framework. Refer to Getting Started with XNA Game Studio Development for a development tutorial.
When you create your new project, the basic code structure is automatically created for you. Within the code that has already been inserted, you can now add various methods and loops. Here’s a brief rundown of the code elements you will want to learn and explore:
- Draw loop: (http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw.aspx ) Used to define frames and screen-render backgrounds and objects.
- Update look: (http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update.aspx ) Used when processing game logic, such as object movement, user input, or processing simulation data.
- Initialize method: (http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.initialize.aspx ) Used to load any nongraphic resource.
- LoadContent method: (http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent.aspx ) Used when loading graphic resources, such as textures and other graphic elements.
As stated, this article is designed to get you started developing apps on the Windows Phone 7 using either the Microsoft Silverlight development dedicated server platform or XNA Game Studio Developer. Links to helpful sites have been provided, but this is only a start. There are extensive information available online and it is strongly recommended that each person perform their own research to locate the proper resources, tutorials, and code samples.
With the proper applications loaded and ready to go, websites bookmarked, and resources and code samples at your fingertips, you’re now ready to explore the exciting development opportunities offered for the Windows Phone 7 platform.
Published at DZone with permission of David Kelley. See the original article here.
Opinions expressed by DZone contributors are their own.