Hello World

Windows Phone 7 offers the ability to write applications using the Silverlight platform, here is the classic Hello World example brought to Windows Phone with C# and Visual Studio 2010 Express for Windows Phone.

Printer Friendly Download Tutorial (365KB) Download Source Code (15.9KB)

Step 1

Start Microsoft Visual Studio 2010 Express for Windows Phone, then Select File then New Project... Select "Visual C#" then "Silverlight for Windows Phone" and then "Windows Phone Application" from Templates, select a Location if you wish, then enter a name for the Project and then click OK, see below:

New Project

Step 2

A Windows Phone application Page named MainPage.xaml should then appear, see below:


Step 3

Then from the Windows Phone Controls section in the Toolbox select the Button control:

Button Control

Step 4

Draw a Button on the Page, see below:

MainPage with Button

Step 5

Then goto the Properties box and change the Name to HelloWorld and the Content property from Button to "display" without the quotes, see below:

Button Properties

Step 6

Double Click on the Button Control and type in the HelloWorld_Click method:

PageTitle.Text = "Hello World";

See Below:

Button Click Event

Step 7

Save the Project as you have now finished the Windows Phone Silverlight application. Select the Windows Phone Emulator option then Select Debug then Start Debugging or click on Start Debugging:

Start Debugging

After you do, the following will appear in the Windows Phone Emulator after it has been loaded:

Application Running

Step 8

Now click where it says "display" and the page title will change to Hello World, see below:

Hello World

Step 9

You can then Stop the application by selecting the Visual Studio 2010 application window and clicking on the Stop Debugging button:

Stop Debugging

That was your first simple application for Windows Phone using Silverlight, you may also deploy your application to a Windows Phone 7 device if you wish and run it there.
Try changing the message shown instead of Hello World, or change the Button caption - there is a lot to learn from this simple example!


Creative Commons License

Copyright Comentsys © 2009 - 2010, All rights reserved. About | Contact | Link to Page
Valid XHTML 1.1! Valid CSS Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 This website is ICRA rated Creative Commons License