[英]Vertical GridSplitter not resizable
I'm trying to make a GridSplitter which can resize rows in a Grid. 我试图做一个GridSplitter可以调整网格中的行的大小。 The Grid is made of three rows, each one has a StackPanel which contains two labels (name, surname, age):
网格由三行组成,每行都有一个StackPanel,其中包含两个标签(名称,姓氏,年龄):
<Grid Background="LightGray">
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<GridSplitter Grid.Row="0" Grid.Column="0" Height="5"
VerticalAlignment="Center"
HorizontalAlignment="Stretch" ResizeDirection="Rows"/>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Label FontSize="25" Margin="10">Name</Label>
<Label x:Name="nameLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Label FontSize="25" Margin="10">Surname</Label>
<Label x:Name="surnameLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<Label FontSize="25" Margin="10">Age</Label>
<Label x:Name="ageLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
</Grid>
With this code the first row isn't resizable. 使用此代码,第一行不可调整大小。 I see the GridSplitter, and I also see the arrow when I pass the mouse over it, but if I drag it the row doesn't get resized.
我看到了GridSplitter,当我将鼠标移到它上面时,我也看到了箭头,但是如果拖动它,则行的大小不会调整。
I usually place the GridSplitter
in its own GridRow
. 我通常将
GridSplitter
放在自己的GridRow
。 This will give you the desired effect: 这将给您所需的效果:
<Grid Background="LightGray">
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Label FontSize="25" Margin="10">Name</Label>
<Label x:Name="nameLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
<GridSplitter Grid.Row="1" Grid.Column="0" Height="5"
HorizontalAlignment="Stretch" />
<StackPanel Orientation="Horizontal" Grid.Row="2">
<Label FontSize="25" Margin="10">Surname</Label>
<Label x:Name="surnameLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<Label FontSize="25" Margin="10">Age</Label>
<Label x:Name="ageLabel" FontSize="25" Margin="10"></Label>
</StackPanel>
</Grid>
尝试将GridSplitter
的VerticalAlignment
设置为"Bottom"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.