Gridsplitter Layout Sample
How to get this code going: Create a Windows Presentation Foundation project named LayoutSample and paste the following code in the specified file.
Paste this code into Window1.xaml:
<Window x:Class="LayoutSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="398" Width="564">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="126" />
<ColumnDefinition Width="288*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,0,0" Name="stackPanel1" Background="AliceBlue">
<!-- Left side content -->
<Label>Left</Label>
</StackPanel>
<Grid Grid.Column="1" Margin="5, 0, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="58" />
<RowDefinition Height="177*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Red">
<!-- Top right content -->
<Label>Top right</Label>
</Grid>
<StackPanel Grid.Row="1" Background="Beige" Margin="0,5,0,0">
<!-- Bottom right content -->
<Label>Bottom right</Label>
</StackPanel>
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Margin="5,0,0,0" Name="gridSplitter2" Height="10" VerticalAlignment="Top" />
</Grid>
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" Name="gridSplitter1" Width="10" VerticalAlignment="Stretch" />
</Grid>
</Window>
Compile and run.
Screenshot:
|