Click here to Skip to main content
15,885,914 members
Articles / Mobile Apps

Build Your First Windows Phone 7 Silverlight Application

Rate me:
Please Sign up or sign in to vote.
4.91/5 (18 votes)
24 Jun 2011Ms-PL2 min read 71.2K   1.2K   36  
Build Your First Windows Phone 7 Silverlight Application
<phoneNavigation:PhoneApplicationPage 
    x:Class="DemoHelloWorldApplication.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"       
    >

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

<Grid.Resources>
    <DataTemplate x:Key="ColorItemTemplate">
        <StackPanel Orientation="Vertical">
            <TextBlock Text="{Binding Path=Key}" Foreground="{Binding Path=Key}" />
        </StackPanel>
    </DataTemplate>
</Grid.Resources>
        
        <!--TitleGrid is the name of the application and page title-->
        <Grid x:Name="TitleGrid" Grid.Row="0">
            <TextBlock Text="Hello World Application - Shai Raiten" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/>
            <TextBlock Text="Colors..." x:Name="textBlockListTitle" Style="{StaticResource PhoneTextPageTitle2Style}"/>
        </Grid>

        <!--ContentGrid is empty. Place new content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1" Loaded="ContentGrid_Loaded">
            <Button Content="Change" Height="70" HorizontalAlignment="Left" Margin="306,19,0,0" Name="btn_start" VerticalAlignment="Top" Width="160" Click="button1_Click" />
            <ListBox Height="477"  ItemTemplate="{StaticResource ColorItemTemplate}"  HorizontalAlignment="Left" Margin="20,149,0,0" Name="list_colors" VerticalAlignment="Top" Width="446" BorderBrush="#FFEB1212" BorderThickness="1" SelectionMode="Single" />
            <TextBlock Height="39" HorizontalAlignment="Left" Margin="20,42,0,0" Name="textBlock1" Text="Pick Color" VerticalAlignment="Top" Width="123" />
            <RadioButton Content="Layout" Height="40" HorizontalAlignment="Left" Margin="20,87,0,0" Name="rad_layout" VerticalAlignment="Top" IsChecked="True" />
            <RadioButton Content="Content" Height="40" HorizontalAlignment="Left" Margin="160,87,0,0" Name="rad_ContentGrid" VerticalAlignment="Top" />
            <RadioButton Content="All" Height="40" HorizontalAlignment="Left" Margin="320,87,0,0" Name="rad_all" VerticalAlignment="Top" Width="160" />
        </Grid>
    </Grid>
    
</phoneNavigation:PhoneApplicationPage>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Architect Sela
Israel Israel
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.

My Blog: http://blogs.microsoft.co.il/blogs/shair/

Comments and Discussions