前言
布局控件Grid 配合 GridSplitter 无需编写任何代码 就能实现网格大小可拖动。
纵向GridSplitter与横向GridSplitter
注意将GridSplitter放在你需要滑动的的位置
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<GridSplitter Grid.Row="0" HorizontalAlignment="Right" Width="10" />
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="10" />
</Grid>
纵向的比较简单
注意,因为是纵向的所以设置的是宽度
<GridSplitter Grid.Row="0" HorizontalAlignment="Right" Width="10" />
横向的复杂一点
注意,因为是横向的所以设置的是高度(这个很重要!),水平方向布局需要进行拉伸(Stretch)
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="10" />