2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 x:Class="Grid_Convert_Value_Csharp.Window1"
5 Title="Dynamically Change Margin Property Sample">
6 <DockPanel Background="White">
8 <TextBlock DockPanel.Dock="Top" FontSize="24" FontWeight="Bold">Grid Margin Property Sample</TextBlock>
9 <Border Border.Background="LightSteelBlue" Border.BorderThickness="2" Border.BorderBrush="Black" DockPanel.Dock="Top">
10 <Grid Name="grid1" Height="400">
11 <Grid.ColumnDefinitions>
13 </Grid.ColumnDefinitions>
16 </Grid.RowDefinitions>
17 <TextBlock Name="text1" FontSize="14" HorizontalAlignment="Center" FontWeight="Bold" Grid.Column="0" Grid.Row="0" Margin="0,0,0,0">Some Text.</TextBlock>
21 <TextBlock DockPanel.Dock="Top" FontSize="14" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,15,0,15">
22 Use the ListBoxes below to manipulate the Margin property of the TextBlock element above.</TextBlock>
24 <Grid HorizontalAlignment="Center" Width="300" DockPanel.Dock="Top">
28 </Grid.RowDefinitions>
29 <Grid.ColumnDefinitions>
30 <ColumnDefinition Width="Auto"/>
31 <ColumnDefinition Width="*"/>
32 </Grid.ColumnDefinitions>
33 <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top">Set the Margin Property of the Grid:</TextBlock>
34 <ListBox Grid.Row="0" Grid.Column="1"
35 Width="50" Height="50"
36 VerticalAlignment="Top"
37 SelectionChanged="ChangeMargin">
38 <ListBoxItem>10</ListBoxItem>
39 <ListBoxItem>20</ListBoxItem>
40 <ListBoxItem>30</ListBoxItem>
41 <ListBoxItem>40</ListBoxItem>
42 <ListBoxItem>50</ListBoxItem>
43 <ListBoxItem>60</ListBoxItem>
44 <ListBoxItem>70</ListBoxItem>
45 <ListBoxItem>80</ListBoxItem>
46 <ListBoxItem>90</ListBoxItem>
47 <ListBoxItem>100</ListBoxItem>
49 <TextBlock Grid.Row="1" Grid.ColumnSpan="2" Name="gridVal"/>