Search

News Update :
Home » , » Learn Silverlight for Windows Phone 7 - [Part-3]

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

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”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.

  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. 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.

Download Source Code and Article

:)

Thank you!

Share this article :

Post a Comment

 
Design Template by panjz-online | Support by creating website | Powered by Blogger