Grid分割窗口

每个windows用户都见过分割条,能将窗口的一部分另一部分分离的可拖动分割器

 

在WPF中,分割条由GridSplitter类表示

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid ShowGridLines="True" UseLayoutRounding="True">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition MinWidth="50"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <Button Grid.Column="0" Grid.Row="0">TOP LEFT</Button>
        <Button Grid.Column="2" Grid.Row="0">TOP RIGHT</Button>
        <Button Grid.Column="0" Grid.Row="1">BOTTOM LEFT</Button>
        <Button Grid.Column="2" Grid.Row="1">BOTTOM RIGHT</Button>
        
        <GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="False"></GridSplitter>