Page 75 分割窗口
一般的分割代码
<Window x:Class="SharedSizeGroup.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>
<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.Row="0" Grid.Column="0" Margin="3">Left</Button>
<Button Grid.Row="0" Grid.Column="2" Margin="3">Right</Button>
<Button Grid.Row="1" Grid.Column="0" Margin="3">Left</Button>
<Button Grid.Row="1" Grid.Column="2" Margin="3">Right</Button>
<GridSplitter Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"
Grid.Row="0" Grid.RowSpan="2"
Width="5" ShowsPreview="False"></GridSplitter>
</Grid>
</Window>
注意事项:VerticalAlignment属性、HorizontalAlignment属性以及Width(Height)属性提供相应的属性值。
我的理解:设置Auto参数时,根据包含的对象设置Width(Height)的值(所有列或行都设置Auto时,从左至右自动设置Width(Height),可能最后的行或列会很大或很小);
设置*参数时,根据剩余空间来的权重比值来分配(Width(Height)默认参数为*,比值1.0);所有设置*参数的行或列为一个集合进行统筹。
所有的行或列都设置*参数的时候则每个列或行根据窗体的大小等比例缩放。(暂时研究到这里,可能有些错误,日后慢慢考证)

浙公网安备 33010602011771号