所以我基本上有以下代码:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions
<TextBlock Grid.Row="0" Grid.Column="0" Text="Row0"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Row1"/>
<GroupBox Grid.Row="0" Grid.RowSpan="3" Grid.Column="1">
<!-- Some stuff here in the GroupBox -->
</GroupBox>
<!-- Some other stuff in Grid.Row="3" -->
</Grid>
发生的情况是前两行的大小未正确调整到其中的 TextBlock,它们的大小受到 GroupBox 的影响。我添加第三行本质上只是为了提供溢出空间,因为 GroupBox 比前两行加在一起高一点,但这也会使前两行的大小增加,类似于我所期望的星星大小的。如果我注释掉 GroupBox,前两行的大小将正确地适合其各自的 TextBlock。关于为什么会发生这种情况以及如何让它做我认为应该做的事情有什么想法吗?
最佳答案
对您的行尝试此设置:
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
关于wpf - 当具有 RowSpan 的项目跨越行时,自动调整大小的网格行会执行奇怪的大小调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28592691/