Learn Silverlight for Windows Phone 7 - [Part-3]

In this article, I will explain how to write a Silverlight Hello World program for Windows Phone 7. This article is absolutely for beginners to learn Silverlight for Windows Phone 7.

It is pretty simple to develop Windows Phone 7 application. It is a cool new mobile platform from Microsoft. Developers use Silverlight, XNA Framework and of course .NET compact framework for developing Windows Phone 7 applications. Programs for Windows Phone 7 are written in .NET managed code using C#.NET.
In this part I am going to describe how to get familiar with windows phone development using very traditional program that is "Hello World".

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.

1. Windows Phone Application
2. Windows Phone Databound Application
3. Windows Phone Class Library
4. Windows Phone Panorama Application
5. 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.Now the UI is ready.

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.

Now I enter the name and click on "Click Me" Button, then a pop-up message will appear on the screen with name.

That's all for the Hello World application for Windows Phone 7. Follow up this series for more advance topics.

Here I have attached source code and this article with pictorial representation in PDF format.

Thank you!


  • Source Code and Article (41645-21335-WP_HelloWorld.zip)
  • Comments

    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: