eugenedotnet home
history      administration      file management


Follow eugenedotnet on Twitter




Windows Phone 7: Introduction and a "Hello World" application

RSS
Modified on 02.08.2010 21:48 by eugenedotnet Categorized as Development, Windows Phone 7




In this lesson I will introduce you to my website and create a simple "Hello World" application.


Requirements:
  • Visual Studio 2010 with Windows Phone Developer Tools
  • Windows Phone 7 emulator
  • Silverlight 4+


After that lesson you will be able to create a very simple Windows Phone application, something like that:
Windows Phone 7 Hello World by eugenedotnet



Important! "Hello World" application in video was created using Windows Phone Developer Tools CTP release. XAML and source code in the end of this lesson are recreated using Windows Phone Developer Tools Beta.



Screencast on YouTube:





Here is a code of MainPage XAML:

<phone:PhoneApplicationPage 
    x:Class="Lesson1_HelloWorld.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
            <TextBlock x:Name="ApplicationTitle" Text="EUGENEDOTNET.COM" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="my first app" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1">
            <TextBlock Height="36" HorizontalAlignment="Left" Margin="113,106,0,0" Name="textBlock1" Text="MyText" VerticalAlignment="Top" Width="156" />
            <Button Content="Say Hello!" Height="70" HorizontalAlignment="Left" Margin="113,180,0,0" Name="button1" VerticalAlignment="Top" Width="179" Click="button1_Click" />
        </Grid>
    </Grid>
   
</phone:PhoneApplicationPage>



Here is a class (code-behind) for MainPage.xaml:

public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        textBlock1.Text = "Hello World!";
    }
}

ScrewTurn Wiki version 3.0.3.555

Guest - Plans - Presentation - Links - Login