After you’ve installed the Windows Phone Developer Tools. By default you will get Visual Studio 2010 express edition, i am using Visual Studio professional edition
- On the Start menu, launch Microsoft Visual Studio 2010
- On the File menu, click New Project
- On the left, select Silverlight for Windows Phone
- In the center, select the Windows Phone Application template
- Name the project PhoneApp2 and click OK
- Select Windows Phone OS 7.1 and click OK
A new Silverlight for Windows Phone project is created and opened in the designer.
On the left is the Design view, in the middle is the XAML view, and on the right is Solution Explorer. This setting can be easily changed.
Solution Explorer provides you with an organized view of your projects and their files as well as ready access to the commands that pertain to them
Extensible Application Markup Language (XAML) is a declarative language. Specifically, XAML can initialize objects and set properties of objects, using a language structure that shows hierarchical relationships between multiple objects, and using a backing type convention that supports extension of types. For more information on solution explorer check MSDN
For more information about XAML, see the XAML Overview on MSDN
Adding a textblock
There are different ways that you can add elements, but this section will use the Toolbox and Design view.
- If toolbox isn’t already open, On the View menu, click Other Windows, and then click Toolbox
- From the Toolbox, drag a TextBlock on to the main panel of the phone
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <TextBlock Height="30" HorizontalAlignment="Left" Margin="102,165,0,0" Name="textBlock1" Text="My First Project" VerticalAlignment="Top" /> </Grid>
- If properties window isn’t already open,On the View menu, click Other Windows, and then click Properties Window. The Properties window appears
- In Design view, make sure that the TextBlock is still selected
- In the Properties window, set the Text property to My First Project
- Set the FontSize property to 50.
- Set the Height property to 70
Running/Debugging the application on computer using emulator
We will use the built-in Windows Phone emulator, which mimics a Windows Phone device. Using the Windows Phone emulator, you can test and debug your application quickly on the desktop without having to deploy the application to the device.
To start the emulator, you simply need to start a debug session for the application. Visual Studio will launch the emulator and load the application onto it.
To start the application in debug mode, press F5 or choose Debug->Start Debugging.
If there are errors compiling your application, Visual Studio will display error information. After a few moments, an emulator window, like the following image, should appear.
It takes a few moments to open the emulator and start the debugger for the first time. To speed up subsequent debug sessions, don’t close the emulator window. Instead, choose Debug->Stop Debugging to stop debugging. This will leave the emulator running, so the next debug session will load more quickly.
To stop debugging, select Debug->Stop Debugging.
Running application on a Windows Phone
To run your application on a Windows Phone, you must unlock the device by using the Windows Phone Developer Registration tool. This tool is located in the Start Menu under Windows Phone Developer Tools. You must have a paid App Hub account.
- Start the Zune software on your computer
- Connect the phone to your computer
- Launch the Windows Phone Developer Registration tool, then enter the Windows Live ID credentials associated with your App Hub account
- In Visual Studio, deploying to the phone is as simple as selecting “Windows Phone Device” (instead of the emulator) in the deployment target
- After selecting Windows Phone Device in the drop-down, you can deploy to the unlocked device by using the same process and debugging techniques as you would with the emulator