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 itJ).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 popup 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.

Thank you!

Advertisements

About Pavan Pareta

My name is Pavan Pareta, I enjoy computers and general technology. I am more interested in the areas of Computer Security, Programming and developing innovative s/w for Windows Mobile and Windows Phone 7. I like MS Technology and support open-source software, because I believe it plays a major role in knowledge sharing and exchange of ideas, which effectively leads to better software. Additionally, I am a follower of the KISS (Keep It Simple Stupid) philosophy. I Love C#.NET and recently I am fall in love with Silverlight :) Introduce to my machine My main workstation is a Intel Pentium Core Duo and my primary operating system is Windows 7.
This entry was posted in Windows Phone 7. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s