我正在尝试在wpf应用程序中使用网格行/列定义。目前,我需要在GroupBox中实现一个列表视图。在这里,我需要忽略在视图顶部设置的列定义。
行和列的定义:
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="260" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
在这里,您看到我的rowDefinition高度为260。其中应该包含我的列表视图。问题在于它在我创建的列中,因此不会占用所有空间。是否有某种设置可以使该行忽略我设置的列?我仍然希望将这些列用于其他行。
在这里,您可以看到有关其外观的图片:
希望有人能帮忙,美好的一天。
只需使用附加属性Grid.ColumnSpan
:
<ListView Grid.ColumnSpan="6"/>
它将扩展您ListView
的6列。
有关您的UI的简单建议:
我建议您创建可调整大小的XAML,而不是静态的。我的意思是不好:
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="260" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
但是,这样更好:
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="3*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
它可以在任何显示器上提供可调整大小的UI(XAML)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句