In this part I am going to describe how to get familiar with windows phone development using very traditional program that is “Hello World”J.
Let us open Visual Studio 2010 or Visual Studio 2010 Express for Windows Phone; here I have VS 2010 Ultimate. Now go to file menu and File à New à Project and then you see a list of project templates of Silverlight for windows phone 7.
- Windows Phone Application
- Windows Phone Databound Application
- Windows Phone Class Library
- Windows Phone Panorama Application
- Windows Phone Pivot application
Now here we have to choose Windows Phone Application Template then enter the project name of the application i.e. (WP_Hello_World) and press OK Button.
Now we are able to view default XAML page in IDE, we can say that it’s a form just like in a windows mobile application development SDK (I know windows mobile developer got it:). here we go…
Here I am going to develop a very simple UI for hello world application. Now we add few controls by dragging and dropping from the Toolbox (TextBlock, TextBox and Button) to the XAML page. After this the XAML will be automatically generated. See in the below picture.
Now the UI is ready, it looks like the picture shown below.
Now just double click on the button control, the following code will be generated in the XAML.cs file which is also known as code behind.
private void btnClickMe_Click(object sender, RoutedEventArgs e)
MessageBox.Show("Hello " + txtName.Text + "!", this.Name, MessageBoxButton.OK);
In the button click event I have used very traditional message box, as we are already aware. This message box class is derived from System.Windows Namespace.
Important: To select the target for WP application for Windows Phone Emulator; which is by default set in the WP project if you want to run your application in Windows Phone Device then you must have to connect your Windows Phone 7 device with your development machine and set the target as Windows Phone Device.
Now our program is ready to execute, now press F5 to run the application in the debug mode or press the combination of Ctrl+F5 to run the application in the release mode. See this picture
Now I enter the name and click on “Click Me” Button, then a pop-up message will appear on the screen with name. See below picture.
That’s all for the Hello World application for Windows Phone 7. Follow up this series for more advance topics.