gpt4 book ai didi

wpf - GridSplitter 未正确分割

转载 作者:行者123 更新时间:2023-12-02 01:29:43 28 4
gpt4 key购买 nike

我有以下网格

<Grid>        
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

我的GridSplitter位于第3行(第4行),定义如下:

<GridSplitter Grid.Row="3"
ResizeDirection="Rows"
Style="{StaticResource HorizontalGridSplitter}"
IsTabStop="False" />
<Style x:Key="HorizontalGridSplitter"
TargetType="{x:Type GridSplitter}">
<Setter Property="Height"
Value="4" />
<Setter Property="HorizontalAlignment"
Value="Stretch" />
<Setter Property="VerticalAlignment"
Value="Stretch" />
<Setter Property="Margin"
Value="0" />
</Style>

当我拖动分割线以分割第 2/4 行时,它并没有真正分割行,看起来网格高度变大了。

最佳答案

GridSplitter 具有三种不同的调整大小行为,如下所示:

Resize Behaviours

GridSplitter 根据所选的 ResizeBehaviour 以及它们的可用空间重新调整指定的两列/行的大小,在您的情况下,您指定了 * 高度之前的行和之后的行的自动高度,这意味着它只能调整之前的行的大小,之后的行将始终保持自动:

enter image description here

要解决此问题,您必须将前后行设置为 Width="*" 并将调整大小行为设置为 ResizeBehavior="PreviousAndNext" > 请参阅以下代码片段:

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GridSplitter Grid.Row="3" ResizeDirection="Rows"
Style="{StaticResource HorizontalGridSplitter}"
IsTabStop="False" HorizontalAlignment="Stretch"
ResizeBehavior="PreviousAndNext" />
</Grid>

最好将所有其他行的高度设置为自动或固定值以避免任何奇怪的行为:)

关于wpf - GridSplitter 未正确分割,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5654467/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com