Results 1 to 10 of 10
  1. #1
    The Photoshop Guy cooljeba's Avatar
    Join Date
    Jun 2004
    Location
    On Your monitor!
    Posts
    587

    Post 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



    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>
    Now we need to change the name of the button. Replace "Button" with "Hello"

    Code:
    <Button Content="Hello" HorizontalAlignment="Left" Margin="993,311,0,0" VerticalAlignment="Top"/>
    Also it is a good practice to give name to the control. So add this property.

    Code:
    <Button Name="btnHello" Content="Hello" HorizontalAlignment="Left" Margin="993,311,0,0" VerticalAlignment="Top"/>
    Now lets edit out TextBox's Text and give it a name too

    Code:
    <TextBox Name="txtSayHello" HorizontalAlignment="Left" Margin="485,317,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="451"/>
    notice I have also removed the string from the Text Property

    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.

    Code:
      private void btnHello_Click(object sender, RoutedEventArgs e)
            {
    
            }
    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.
    Write the following c# code .
    Code:
     private void btnHello_Click(object sender, RoutedEventArgs e)
            {
                txtSayHello.Text = "Hello " + txtSayHello.Text;
            }
    Running the Metro Application
    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 forum
    Last edited by cooljeba; 28-08-2012 at 02:20 PM.

  2. #2
    Wise Old Mouse mrintech's Avatar
    Join Date
    Sep 2005
    Location
    Bhopal, India
    Posts
    2,081

    Default 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 :)

  3. #3
    Project Halcyon V2.1 tkin's Avatar
    Join Date
    Aug 2008
    Location
    Hyderabad, India
    Posts
    9,160

    Default 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


  4. #4
    The Photoshop Guy cooljeba's Avatar
    Join Date
    Jun 2004
    Location
    On Your monitor!
    Posts
    587

    Default Re: For newbies : writing your first windows 8 metro application

    thanks guys

  5. #5
    Alpha Geek funskar's Avatar
    Join Date
    Sep 2011
    Location
    India
    Posts
    530

    Default Re: For newbies : writing your first windows 8 metro application

    Thankx..
    Spoiler:
    ||i5-2500K|Ga Z68xp-Ud4|Ripwas X 8gb|Vx550|Seagate 1Tb+500Gb+250gb|Asus Xonar Dx 7.1|Logitech Z906|Xbox 360 Controller|Haf 922|Ps3|No Gpu-Sub 20k Gpu Cuming Soon


    If you Don't have a UID card Then Visit Bangladesh Once n buy it for 100 Inr..

  6. #6
    rated R ritvij's Avatar
    Join Date
    Apr 2010
    Location
    Gorakhpur
    Posts
    386

    Default 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:

  7. #7
    VIP RazorbladeXtreme's Avatar
    Join Date
    May 2008
    Location
    Jaipur
    Posts
    239

    Default 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

  8. #8
    The Photoshop Guy cooljeba's Avatar
    Join Date
    Jun 2004
    Location
    On Your monitor!
    Posts
    587

    Default Re: For newbies : writing your first windows 8 metro application

    Yes.. Programming using .net framework is pretty easy..

  9. #9
    The Photoshop Guy cooljeba's Avatar
    Join Date
    Jun 2004
    Location
    On Your monitor!
    Posts
    587

    Default Re: For newbies : writing your first windows 8 metro application

    updated the path of solution file

  10. #10
    Apprentice velociraptor's Avatar
    Join Date
    Dec 2011
    Posts
    70

    Default 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;


Similar Threads

  1. Replies: 6
    Last Post: 29-08-2011, 06:24 PM
  2. Writing application for net usage
    By arpanmukherjee1 in forum Programming
    Replies: 10
    Last Post: 27-03-2011, 02:24 PM
  3. How to start writing GNOME/KDE application
    By sganesh in forum Open Source
    Replies: 29
    Last Post: 24-08-2008, 07:09 AM
  4. program writing in windows
    By rameeze in forum Programming
    Replies: 11
    Last Post: 07-05-2008, 10:52 PM
  5. Newbies guide to Windows ownership tricks
    By Siddharth Maheshwari in forum Tutorials
    Replies: 6
    Last Post: 24-01-2007, 12:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Close