Introduction to Silverlight > Using Templates > Data Templates > Create the "Templates" Solution |
To illustrate the power of DataTemplates, let's create a new Silverlight solution. Call it "Templates". Complete the following steps:
XAML |
Copy Code
|
---|---|
<UserControl x:Class="Templates.MainPage" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:C1_Silverlight="clr-namespace:C1.Silverlight;assembly=C1.Silverlight"> <Grid x:Name="LayoutRoot" > <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF7EB9F0"/> <GradientStop Color="#FF284259" Offset="1"/> </LinearGradientBrush> </Grid.Background> <!-- Grid layout --> <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <!-- Page title --> <TextBlock Text="Silverlight Templates" Grid.Column="0" Grid.ColumnSpan="2" TextAlignment="Center" FontSize="18" FontWeight="Bold" /> <!-- ListBox on the left --> <StackPanel Grid.Row="1" Margin="5" > <TextBlock Text="ListBox Control" /> <ListBox x:Name="_listBox" /> </StackPanel> <!-- C1ComboBoxes on the right --> <StackPanel Grid.Column="2" Grid.Row="1" Margin="5" > <TextBlock Text="C1ComboBox Controls" /> <C1_Silverlight:C1ComboBox x:Name="_cmb1" Margin="0,0,0,5" /> <C1_Silverlight:C1ComboBox x:Name="_cmb2" Margin="0,0,0,5" /> </StackPanel> </Grid> </UserControl> |
This creates a page with two columns. The left column has a standard ListBox control and the right has two C1ComboBoxes. These are the controls we will populate and style in the following steps.