You Had Me At "Hello World" (Silverlight For Windows Phone)

Any programming journey begins by the time coders write their first line of hello world. The first lesson in this Windows Phone e-book should be no different. To keep up with that tradition, here are the steps to make your Windows Phone say hello:

1. Open Visual Studio Express for Windows Phone. Select File -> New Project. Choose the Visual C# Silverlight for Windows Phone template. Select Windows Phone Application and name the project to your liking.

tmp1C-1

2. After the project is created, the screen will show design and XAML markup codes. Design view shows the phone interface which enables us to see how our program looks like during the development. For those of you who are already familiar with Visual Studio, then the Tool Box panel, Solution Explorer, and Properties pane will be around your main view.

tmp1C-2


3. Add a TextBox and a Button from the ToolBox. Note that we get the same experience in developing Silverlight for web applications. We can easily alter the interface from the Properties pane.

tmp1C-3

When a Button is selected, we can see that the button is highlighted with a box outside the Button’s border. The box indicates the Button’s touch area. This property is owned by every control. Change the title text in XAML into "Hello World".

4. Double-clicking the Button will show codes behind the active page. Add a function to change Title into "Hello +" input from available TextBox.

tmp1C-4

5. Type this code for the Button’s event handler,

tmp1C-5_thumbtmp1C-6_thumb

6. Now we can test the simple application we have made. To deploy and launch the application we can choose between running in an emulator or available Windows Phone device. Since there are not many deployable Windows Phone yet, let’s use the emulator to run this simple application. Press F5 and see the result.

tmp1C-7

First-time deployment may take some time to process. However, the next deployments will take less time, provided we don’t shut down the emulator. Type any text in the TextBox and press the button. The title in the page will change according to the text inserted into TextBox. This is your first Windows Phone application. Congratulations! :)

tmp1C-8

Next post:

Previous post: