Results 1 to 10 of 10
-
21-07-2012, 09:56 AM #1
For newbies : writing your first windows 8 metro application
In this tutorial we will see how to create your first Windows 8 Metro app. For example we will code a simple "Hello Name" application. This application will ask for a name and print the same with a greeting. This is a very basic tutorial and it requires no previous coding experience.
You will also learn how to compile and Run your metro application inside a simulator right from Visual Studio.
Creating your First Project
Launch Visual Studio and Select File > New Project

Select Templates > Visual C# > Windows Metro Style and Press OK. Visual studio will now create the solution and the corresponding xaml, cs files.

Open up Solution Explorer to see the files it has created. (ctrl + w + s) or choose View > Solution Explorer in Visual Studio

Adding Controls to the Designer
Double click on MainPage.xaml in Solution explorer to open up the Designer View. Here we will add our controls. For this tutorial we will be using a TextBox and a Button control.
The TextBox will be used to show the Greeting and the Entered Name when the button is clicked.
Select View > Toolbox to see the Toolbox menu. This holds all the usable controls required for development. You can dynamically create controls directly on the Xaml files but I will show that in another tutorial.

For now Just drag and drop the Button and Text box to your MainPage.xaml designer. You should see something like this. Use the mouse to resize the control to your liking.

Adding Code to our Application
Now click on the XAML button at the bottom left screen to reveal the code. It should look something like right now

Now we need to change the name of the button. Replace "Button" with "Hello"Code:<Page x:Class="HelloWorld.MainPage" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:HelloWorld" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <Button Content="Button" HorizontalAlignment="Left" Margin="993,311,0,0" VerticalAlignment="Top"/> <TextBox HorizontalAlignment="Left" Margin="485,317,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="451"/> </Grid> </Page>
Also it is a good practice to give name to the control. So add this property.Code:<Button Content="Hello" HorizontalAlignment="Left" Margin="993,311,0,0" VerticalAlignment="Top"/>
Now lets edit out TextBox's Text and give it a name tooCode:<Button Name="btnHello" Content="Hello" HorizontalAlignment="Left" Margin="993,311,0,0" VerticalAlignment="Top"/>
notice I have also removed the string from the Text PropertyCode:<TextBox Name="txtSayHello" HorizontalAlignment="Left" Margin="485,317,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="451"/>
Now switch back to Design View . It is located at left bottom same place where you clicked XAML. You will now see that the button name has been renamed to Hello and the content of textbox has gone.
Now let us add some c# code to achive our requirement.
Double click on your Hello button, this will create a "Click" event and add it to your .cs file.
Here we will add the code which gets fired everytime some clicks on the Hello button. We want to take up the Text entered into the TextBox and Add hello in the begining.Code:private void btnHello_Click(object sender, RoutedEventArgs e) { }
Write the following c# code .
Running the Metro ApplicationCode:private void btnHello_Click(object sender, RoutedEventArgs e) { txtSayHello.Text = "Hello " + txtSayHello.Text; }
Now we are going to compile and run it in the simulator.
After you have chosen where the code will run Press F5. This will deploy the binaries into the simulator and execute it from there.

Download the solution file at Surface forumLast edited by cooljeba; 28-08-2012 at 02:20 PM.
-
21-07-2012, 01:16 PM #2
Re: For newbies : writing your first windows 8 metro application
Thanks a lot for detailed tutorial
MrinTech | Exam Dunia :)
Some gadgets I own: Dell Inspiron 15R | Asus X53U-SX013D | iPad 2 | Samsung Galaxy S+ | PS3 :)
-
21-07-2012, 04:31 PM #3
Re: For newbies : writing your first windows 8 metro application
Thanks.
Project Halcyon V2.1
2600k/Z68VPro/Vengeance/U12PSE2/TX750v2/1TB.Black/DRWB5ST/HAF912+A
M35/PortaPro/E30/Optimus.L9/Siberia/5800XM/FZ150/SH14/FiiO.E6
Dell.15R/Ci3.3110m/7670m/ALVS4621/Funbook/Ferox
-
21-07-2012, 05:58 PM #4
Re: For newbies : writing your first windows 8 metro application
thanks guys
-
22-07-2012, 12:43 AM #5
Re: For newbies : writing your first windows 8 metro application
Thankx..
Spoiler:
If you Don't have a UID card Then Visit Bangladesh Once n buy it for 100 Inr..
-
22-07-2012, 09:57 AM #6
Re: For newbies : writing your first windows 8 metro application
super thanks bud.. no option of rep why??
this is great!I love TDF.. Everyone loves TDF.. Therefore, I am everyone.. :Problem? :D:
-
22-07-2012, 12:15 PM #7
Re: For newbies : writing your first windows 8 metro application
Thanks for the tutorial. Turns out that metro app coding is much similar to web application coding, I think getting hang of it wouldn't be a problem
Twitter: twitter.com/SharmaTushar
Facebook: facebook.com/tushar.sharma
-
22-07-2012, 02:25 PM #8
Re: For newbies : writing your first windows 8 metro application
Yes.. Programming using .net framework is pretty easy..
-
28-08-2012, 02:21 PM #9
Re: For newbies : writing your first windows 8 metro application
updated the path of solution file
-
28-09-2012, 01:39 PM #10
Re: For newbies : writing your first windows 8 metro application
um it looks very interesting i also want to learn how to develop app so please tell me the prerequisites i mean the software u used and the language ...please,,t hanx in advance
please provide the link to download that development tool tooo ...hp-dv6 6165tx 2gb ddr5 hd6770m, 8 gig of ram ,i7 2670qm 2.2Ghz,750 gb hdd,win 7 professional,linux mint lisa;
LinkBacks (?)
-
For newbies : writing your first windows 8 metro application - Digit Technology Discussion Forum
Refback This thread23-07-2012, 12:38 AM
Similar Threads
-
Mosaic project: an application that brings Windows 8 Metro UI to Windows 7
By Garbage in forum Technology NewsReplies: 6Last Post: 29-08-2011, 06:24 PM -
Writing application for net usage
By arpanmukherjee1 in forum ProgrammingReplies: 10Last Post: 27-03-2011, 02:24 PM -
How to start writing GNOME/KDE application
By sganesh in forum Open SourceReplies: 29Last Post: 24-08-2008, 07:09 AM -
program writing in windows
By rameeze in forum ProgrammingReplies: 11Last Post: 07-05-2008, 10:52 PM -
Newbies guide to Windows ownership tricks
By Siddharth Maheshwari in forum TutorialsReplies: 6Last Post: 24-01-2007, 12:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks