XAMLの全コード
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="400" Width="600">
<Grid x:Name="LayoutRoot" Width="400" Height="300" Background="LightGreen">
<!-- Grid レイアウトの行、および列の定義 -->
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
Fill="GreenYellow" />
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
VerticalAlignment="Center" HorizontalAlignment="Center"
FontSize="16" Text="Silverlight Layouts" />
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top"
Text="Figures:" />
<!-- Canvas レイアウト -->
<Canvas Grid.Row="1" Grid.Column="1" Background="LightBlue" >
<Ellipse Canvas.Left="50" Canvas.Top="30"
Width="150" Height="80" Fill="Gold" />
<Rectangle Canvas.Left="120" Canvas.Top="80"
Width="120" Height="90" Stroke="DarkBlue" StrokeThickness="7" />
</Canvas>
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center"
Text="Name: " />
<TextBox Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left"
Width="200" />
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center"
Text="Gender:" />
<!-- StackPanel レイアウト -->
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" Background="Khaki">
<RadioButton x:Name="genderMale" Content="Male" IsChecked="True" />
<RadioButton x:Name="genderFemale" Content="Female" />
</StackPanel>
</Grid>
</Window>