It often surprises me how much of content is available to develop for Windows Phone, if you are looking for baby steps this series of lessons is defiantly not for you. However, if you are developer, regardless of background or platform and looking quickly to get your hands dirty, then you are at the right place. I will not be setting up a fixed or target number of lessons, I will share ideas along the way and keep adding more. This does not mean I don’t have an agenda, on the contrary! I started by asking myself about developer tasks during the life cycle of building an application, and came up with this:
and the list will keep on growing
To get you up to speed, you need to download the Windows Phone SDK 8.0 from: http://dev.windowsphone.com/en-us/downloadsdk.
As I mentioned earlier, this a special series that focuses on a point, a task, a recipe. So don’t be surprised if we wont be building fancy samples, I am here to help you get on your feet with Windows Phone Development as soon as possible.
You can always find the lesson source code attached at the end of the blog post.
There are lots of controls for you to do so like a Grid, a Canvas, or my favorite a StackPanel. In this lesson we will use the StackPanel to describe our page layout.
I love StackPanels because you can stack controls on either horizontally or vertically with now swat, you can even have a StackPanel stacking another StackPanel, how cool is that?
Check the code below: I laid 2 StackPanels inside the ContentPanel, one with Horizontal orientation and the second with Vertical orientation each containg 4 buttons.
and then check the designer screenshot rendering both StackPanels below:
XAML is simple to use, we use the tags to layout controls and predefined properties to describe their behavior or format. You will get used to it quickly.
A lame sample indeed , So I was thinking of asking the user to enter 2 numbers and then we multiply them and return the result either in a message box or simple push it back in a label somewhere on the page for the user. It will look like this one below:
Layout is simple, we have 2 StackPanels like the first example above with the 4 buttons, but this time instead of stacking buttons in the first StackPanel, I stacked text and input boxes. From now on, we refer to text on application page as TextBlock and input boxes as TextBox.
Notice that I added an InputScope to the TextBox telling the application that we want the numbers keyboard to show up instead of the normal full keyboard when capturing user input:
We have a the layout ready and all we need to do is tell out application how to behave when something happens on the GUI aka an Event.
The SDK comes equipped with an Emulator, we will cover this in later lessons, but for now just hit ctrl+F5 to Build and Deploy our application to the emulator and run it. Please be patient and wait until it loads our application. Once loaded, enter some values for X and Y. Notice how the numbers keyboard is shown instead of the full keyboard.
Now try once to tap the Messagebox button and another time the TextBlock button.
I hope you enjoyed the lesson, to sum it up:
Let me know if you have any questions