In our last tutorial, we saw the overview of Windows Phone 7.5 aka Mango and its developer tool. Now before we move on, I want to clarify one thing. Some of you might be thinking that what exactly is the difference between Windows Phone 7 and its latest upgraded version 7.5?
Well, the answer is as all upgrades do, Windows Phone 7.5 aka mango has brought some fine features to the smart phones like Bing Vision, Bing Audio, SMS dictation and Turn-By-Turn navigation extending Windows Phone 7’s functionality further. Newly launched Windows Phone 7.5 also sports Windows Live Messenger integrated into people hub and Bing image search.
Now, let us get back to our main tutorial subject and that is Application Development for Windows Phone 7.5. Now as we seen in last tutorial, there are 2 sections of a developer page, namely C# section, XAML section and Solution explorer and visual section. There is another sub section which you probably would have come across by now and that is Windows Phone Emulator section.
Let us write a simple application assuming that you already know basic syntax of C#. In this application, we will have one button and one text block. Upon clicking button, the textblock will display some text, all pretty simple! Although it will be a simple app, it will give you overall idea about developing an app for Windows Phone 7.
Now create a new project with any suitable name, but for reference let’s develop habit of naming projects as test 1, test 2 and so on. So after creating test 1 project, you will get familiar screen of Windows Mobile 7 developer’s tool.
Now pull down a button and a text block from toolbox to your lower section of Visual section, i.e. on the copy of Windows Phone Emulator. Position them suiting your choice, only make sure that you text block is bigger enough to contain several words.
After you have dropped these controls on layout, label them with some meaningful name using property menu (e.g. for textblock - txtop). Now it is the time to write the first line of code in our very first program.
Now we want something to happen when we click buttons, so double-click on button control placed in layout. You will get a new Window for writing C# code (see image).
So in the pair of curly braces, write this code:
txtop.text = “hello”;
After saving this project run it by pressing F5. Emulator screen will pop-up and you will get your button and textblock on its screen. Now try pressing the button. Ta-da, congrats you just have successfully created your first application on Windows Phone 7.5.
Let us now dissect our application in brief. Clicking button twice created a button_click event which specifies what should happen when user click on that button in run-time. We defined that if user presses this button, textblock’s text property should be changed to “Hello World” and thus we got “Hello world” in run-time.
In the next chapter we will take a look at what are variables, how to declare them and how to accept input and assign value to textboxes.
P.S. You can find more about naming conventions and default properties of controls on the Internet.