Windows 8 is the hot topic in the Operating Systems market; it is not yet launched but its preview versions are making a great impression among developers. It has launched three versions so far; Developer Preview, Consumer Preview and Release Preview. The Windows App Store in Windows 8 is the major attraction. In this article I will get you started with Windows 8 application development.
Starting with development, we need some developer tools for Windows 8:
- Visual Studio 11 or Visual Studio 12 RC
- Windows 8 SDK
- App Certification Kit
Well if you use Visual Studio 12 RC it contains all the developer tools, though Visual Studio 12 RC cannot be installed onto the Consumer Preview; for this you need either Developer Preview or Release Preview.
Create a new project. Under the templates section you will see Windows Metro Style:
There are three types of apps which can be developed:
- Blank App - Is the minimal application for a Windows Metro style framework. It is used to create basic applications.
- Grid App - This can be used to create multi-page projects for navigating multiple layers of contents with item details displayed on a detailed page. This can be used to create a panoramic view also.
- Split App - This defines two different sections where you can create a project for navigating among a master list of items while viewing their details on the same page.
For this article I'm using a Blank App Type. The following figure will clarify everything I'm talking about:
Now that the new project is created and the MainPage.xaml will show in the main window, other files can be browsed from the Solution Explorer. We have a ToolBox on the left from which various controls can be dragged and dropped to the design view of the MainPage.xaml or we can directly write some XAML code to add the control. Since this is this first app we are going to make, we will simply add a TextBlock and add some text to it which will be shown when the app is loaded. The following figure will show you the code snippet:
Consider the first line; here MyFirstApp is the namespace and MainPage is the class. We have added a control TextBlock and added a few attributes like HorizontalAlignment and VerticalAllignment, we have set both of them to Center so that our text comes in center. And now you are done with your very first and simple application. This can be debugged in various modes like debug in the Local Machine, Simulator and Remote Machine. I prefer debugging it in the Simulator. It will look something like this: