2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 x:Class="SDKSample.Window1"
5 Title="GridUnitType.Star Sample"
9 <TextBlock FontSize="20" Margin="15">Understanding Star Sizing</TextBlock>
10 <TextBlock FontSize="14" TextWrapping="Wrap" Margin="10">Use the Buttons below to change the Width properties of the ColumnDefinition and RowDefinition elements.
11 Notice that unallocated space is distributed proportionally to the row or column based on the increment selected (1*, 2*, or 3*).</TextBlock>
12 <TextBlock FontSize="14" Margin="10">First, select the Column and Row that you want to apply Star values to:</TextBlock>
13 <StackPanel Orientation="Horizontal" Margin="10,0,0,5">
14 <ListBox Name="columnSelection" Height="30" SelectionMode="Single" SelectionChanged="setCol" Margin="0,0,5,0">
15 <ListBoxItem>colDef1</ListBoxItem>
16 <ListBoxItem>colDef2</ListBoxItem>
17 <ListBoxItem>colDef3</ListBoxItem>
19 <ListBox Name="rowSelection" Height="30" SelectionMode="Single" SelectionChanged="setRow">
20 <ListBoxItem>rowDef1</ListBoxItem>
21 <ListBoxItem>rowDef2</ListBoxItem>
24 <TextBlock FontSize="14" Margin="10">Next, choose which Star value to apply to the Row or Column (default is colDef1 and rowDef1).</TextBlock>
25 <StackPanel Orientation="Horizontal" Margin="10,5,0,0">
26 <Button Background="LightSteelBlue" Click="colOneStar" Width="150">Column Width = 1*</Button>
27 <Button Background="LightSteelBlue" Click="colTwoStar" Width="150">Column Width = 2*</Button>
28 <Button Background="LightSteelBlue" Click="colThreeStar" Width="150">Column Width = 3*</Button>
30 <StackPanel Orientation="Horizontal" Margin="10,0,0,5">
31 <Button Background="SteelBlue" Click="rowOneStar" Foreground="White" Width="150">Row Height = 1*</Button>
32 <Button Background="SteelBlue" Click="rowTwoStar" Foreground="White" Width="150">Row Height = 2*</Button>
33 <Button Background="SteelBlue" Click="rowThreeStar" Foreground="White" Width="150">Row Height = 3*</Button>
35 <StackPanel Margin="5">
36 <TextBlock Name="txt1"/>
37 <TextBlock Name="txt2"/>
38 <TextBlock Name="txt3"/>
39 <TextBlock Name="txt4"/>
41 <Grid Height="400" Width="800" Name="myGrid" ShowGridLines="True" Margin="10">
42 <Grid.ColumnDefinitions>
43 <ColumnDefinition Width="Auto"/>
44 <ColumnDefinition Width="Auto" Name="colDef1"/>
45 <ColumnDefinition Width="Auto" Name="colDef2"/>
46 <ColumnDefinition Width="Auto" Name="colDef3"/>
47 </Grid.ColumnDefinitions>
49 <RowDefinition Height="25"/>
50 <RowDefinition Height="Auto" Name="rowDef1"/>
51 <RowDefinition Height="Auto" Name="rowDef2"/>
52 </Grid.RowDefinitions>
54 <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center">colDef1</TextBlock>
55 <TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center">colDef2</TextBlock>
56 <TextBlock Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center">colDef3</TextBlock>
58 <TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">rowDef1</TextBlock>
59 <Rectangle Name="rect1" Fill="LightSteelBlue" Width="100" Height="100" Grid.Row="1" Grid.Column="1"/>
60 <Rectangle Name="rect2" Fill="SteelBlue" Width="100" Height="100" Grid.Row="1" Grid.Column="2"/>
61 <Rectangle Name="rect3" Fill="DarkSlateGray" Width="100" Height="100" Grid.Row="1" Grid.Column="3"/>
63 <TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">rowDef2</TextBlock>
64 <Ellipse Name="ellipse1" Fill="LightSteelBlue" Width="100" Height="100" Grid.Row="2" Grid.Column="1"/>
65 <Ellipse Name="ellipse2" Fill="SteelBlue" Width="100" Height="100" Grid.Row="2" Grid.Column="2"/>
66 <Ellipse Name="ellipse3" Fill="DarkSlateGray" Width="100" Height="100" Grid.Row="2" Grid.Column="3"/>
69 <StackPanel HorizontalAlignment="Center" Margin="10">
70 <Button Click="resetSample">Reset Sample</Button>