Wednesday, December 7, 2011

Hello World in Windows Phone

In this tutorial we'll look at basics in Windows Phone Development and we will create a basic Hello World Application. 

1. After installing the Windows Phone Developer Tools, on the start menu open  Microsoft Visual Studio 2010 Express for Windows Phone.

2. Go to file menu and select new project. 

Here there are variety of options to choose from. To understand the basics, we will just    create a simple 'Windows Phone Application'.

3. Select 'Windows Phone Application' and give the project name (WindowsPhoneApplication1). Then select the location where you want to save your project. Press Ok. Visual Studio will create the project.

4. By default Visual Studio is divided into 3 panes. On the left you have the design view, On the middle you have XAML code and in the right you have Solution Explorer and Properties. 



The design view displays how the application will be look on the phone. You can drag and drop elements from Toolbox on to this. 

The XAML(Extensible Application Markup Language) file will be auto-generated when you're adding elements from toolbox to the design view. XAML file is a XML File which is used by visual studio to create the layout and to generate elements. For more information look at this article at MSDN


5. Let's get back to the tutorial. Now we'll add a TextBlock to display text in our application. Go to the toolbox and drag and drop a TextBlock in to the design view. Notice in the XAML that TextBlock element was added inside Grid. 


You can change these properties from either properties window or by manually adding elements to the XAML code. We'll do from properties window. 

6. Select the TextBlock you added and Increase the font size, height and text from Properties Window. You can see that XAML code is changed and elements are added accordingly.


7. Ok. Now we'll run the application. For this we will use the Windows Phone Emulator. Press F5 or go to Debug -> Start Debugging. For the first launch the emulator might take some time to load. 



In the next tutorial we will dig into some user interaction.

No comments:

Post a Comment