How to create your first Windows Store application?
Let’s open the Visual Studio 2012 IDE and go to File – New – Project to create a new Windows Store project. From the Visual C# category, we will select the Windows Store template category. In the right panel, chose Blank App (XAML) and give a good name (in our case, it is “HelloWorld”). Now click “OK” to continue. Momentarily the IDE will start creating your first project.Once the project has been created by the IDE, open the MainPage.xaml file and add a TextBlock from the toolbox inside the Grid as shown below:
Select the TextBlock and move to the Properties panel. There you can set the text property of the control. Visual Studio 2012 gives a proper way to bind styles from the local resource. Click the small rectangle near to the Style property, navigate to Local Resource and from the secondary menu, select a style (e.g. HeaderTextStyle) as shown in the below screenshots:
Here is the XAML code of what we have designed just now:
<Page x:Class="HelloWorld.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<TextBlock HorizontalAlignment="Left" Height="101" Margin="81,99,0,0"
TextWrapping="Wrap" Text="Hello World" VerticalAlignment="Top"
Width="598" Style="{StaticResource HeaderTextStyle}"/>
</Grid>
</Page>
Now in the design window, you will see similar to the above screen. You can drag other controls too and create your own UI for your first “HelloWorld” Windows Store application. Once your application design is ready, you can build and run that app to see what we developed just now.
Building and Running the Windows Store application
It’s time to build the project and run it to see our application running inside Windows 8. You can chose any one of the three options that Visual Studio 2012 provides to test our app. You can chose between the following locations:- Simulator – The app will be deployed in a simulator
- Local Machine – The app will be deployed in your local development machine
- Remote Machine – The app will be deployed in a remote Windows 8 PC
You can chose the one where you want to deploy and test your application. In our case, we will deploy it to Simulator to see how it looks inside a tablet. Here is the screenshot of the application hosted in the simulator:
Now you are done with your first Windows Store application using Visual C# (XAML) and now you will be able to develop more applications using that simple project template.
No comments:
Post a Comment