Building Your First Windows Phone 7 Application (part 1) - Creating a Windows Phone Project

1/16/2011 9:22:42 AM

Preparing Your Development Machine

At the time of writing this book, Windows Phone 7 developer tool beta version 1.0 was used. The latest Windows Phone developer tool can be downloaded from The Windows Phone developer beta tools (vm_web.exe) will install the following:

  • Any commercial version of Visual Studio 2010 or free version of Visual Studio 2010 Express for Windows Phone: Programmer's development IDE.

  • Windows Phone emulator: Used to run and test the Windows Phone application.

  • Silverlight for Windows Phone: Silverlight Framework for Windows Phone based on Silverlight 3 technology.

  • Microsoft Expression Blend for Windows Phone: Can be used to design user interfaces.

  • XNA Game Studio 4: Tools for developing games.

In this section, you'll build a simple "HelloWorld" application using Silverlight framework. Creating the application will provide you with an opportunity to use Visual Studio 2010 Express for Windows Phone, the Windows Phone 7 Emulator, and some Windows Phone Silverlight controls.

1. Creating a Windows Phone Project

To get started, you first fire up Visual Studio Express 2010 and create a project.

  1. To launch Visual Studio 2010 Express, select Windows Start => All Programs =>Microsoft Visual Studio 2010 Express => Microsoft Visual Studio 2010 Express for Windows Phone.

  2. Create a new project by selecting File => New => Project on the Visual Studio menu, as shown in Figure 1.

    Figure 1. Creating a new project
  3. From among the three C# templates that Visual Studio displays on its New Project dialog page, select the Windows Phone Application Visual C# template, as shown in Figure 2.


    There are three different Windows Phone Visual Studio project templates. The Windows Phone Application template is a template for one-page applications. The Windows Phone List Application template uses ListBox control and page navigation framework to create applications with multiple pages. The Windows Phone Class Library template can be used to create a class library that can be referenced by other Windows Phone projects.

  4. For the purposes of this exercise, change the Name of the new project to "HelloWorld," by changing the text in the Name box, as shown in Figure 2. Also you can change the location where the project will be saved by changing the path in the Location box.

    Figure 2. Creating a new Silverlight Windows Phone application
  5. Finally, select OK on the New Project dialog, and Visual Studio 2010 will build your project, whose elements are displayed in Figure 3.

Figure 3. HelloWorld Silverlight Windows Phone project

By default two TextBlock controls will be placed in Windows Phone, and you can see this in design view on the far left in Figure 3.

With a phone project ready to roll, it's time to bring the application to life by adding some functionality and creating a user interface. We'll start with the interface, adding some controls to its blank design surface for users to press and in which the application can display text.

  •  Introducing Windows Phone 7 and the Windows Phone Platform
  •  Windows Phone Application Platform
  •  iPhone Application Development : Basic User Input and Output
  •  Mobile Phone Game Programming : A Quick J2ME Primer
  •  Mobile Phone Game Programming : Java As a Mobile Game Platform
  •  Mobile Phone Game Programming : Getting to Know Mobile Platforms
  •  Mobile Application Security : The Apple iPhone - Local Data Storage: Files, Permissions, and Encryption
  •  Mobile Application Security : The Apple iPhone - Permissions and User Controls
  •  iPhone Application Developmen : Using the View-Based Application Template (part 3)
  •  iPhone Application Developmen : Using the View-Based Application Template (part 2) - Preparing the View Controller Outlets and Actions
  •  iPhone Application Developmen : Using the View-Based Application Template (part 1)
  •  Mobile Application Security: Application Format
  •  Mobile Application Security: Security Testing
  •  Mobile Application Security: The Apple iPhone - Development
  •  Building Android Apps : Installing KiloGap in the Emulator
  •  Building Android Apps : Build KiloGap
  •  Building Android Apps: Create an Android Virtual Device
  •  Building Android Apps: Going Native - Setting Up the Environment
  •  Building Android Apps: Introduction to PhoneGap
  •  iPhone Application Development : How Xcode and Interface Builder Implement MVC
    Top 10
    SQL Server 2008 : Working with DML Queries - Using the DELETE Statement
    Host-Based Security in Windows Vista
    Designing and Configuring Unified Messaging in Exchange Server 2010 : Unified Messaging Features
    Understanding Active Directory Certificate Services (AD CS) in Windows Server 2008 R2
    Changes to Backup and Restore in Exchange Server 2010
    Managing Exchange Server 2010 : Role Based Access Control (RBAC)
    Designing and Implementing Mobility in Exchange Server 2010 : Working with Windows Mobile Pocket PC and Smartphone Editions
    Windows Phone 7 Development : Revising WeatherRx to Manage Slow Data Connections
    Windows Server 2008 R2 Benefits for Administration
    BizTalk 2006 : Editing and Resubmitting Suspended Messages (part 2) - Pseudo-Walkthrough to Perform Edits and Resubmits
    Most View
    Windows Azure : Messaging with the queue - Patterns for message processing
    SQL Azure : Database Growth-Management Strategies
    Deploying a Public Key Infrastructure with Windows Server 2008 R2
    iPhone Application Development : Making Multivalue Choices with Pickers - Using Date Pickers (part 2) - Adding a Date Picker
    Sharepoint 2007: Approve or Reject a File or List Item
    Exchange Server 2010 : Utilize the Availability Options for Servers Based on Role (part 1) - Load-Balance Client Access Servers
    iPhone Application Development : Making Multivalue Choices with Pickers - Using Date Pickers (part 1)
    Programming the Mobile Web : JavaScript Libraries
    Create Bookmark Create Note or Tag Backing Up Windows Server 2008 and Exchange Server 2010
    Filtering Out Evil with Firewalls (part 3) - Manually Configuring a Firewall's Ports
    Mobile Application Security : Bluetooth Security - Bluetooth Technical Architecture
    .NET Debugging : PowerDbg (part 1) - Installing PowerDbg & Analyze-PowerDbgThreads
    Maintaining Windows 7 with Backup and Restore (part 2) - Using Advanced Backup Options & Using System Protection
    Parallel Programming with Microsoft .Net : Parallel Aggregation - Design Notes
    Programming with DirectX : Projection Transformations
    Programming with DirectX : Shading and Surfaces - Additional Texturing Topics
    Outlining AD DS Changes in Windows Server 2008 R2 (part 3) - Auditing Changes Made to AD Objects
    Exchange Server 2010 : Developments in High Availability (part 3) : Backup and restore
    Sharepoint 2007: Get Started with Your Personal Site