包含 GridSplitter-s 的网格内的边框与所有后续行重叠
Border inside a Grid containing GridSplitter-s overlaps all following rows
我正在尝试使用 WPF 创建一个网格,其中包含一个列表视图,然后是一些带有详细信息的控制器,然后是带有单个按钮的一行。这是我试过的
<Grid DataContext="...">
<Grid.RowDefinitions>
<RowDefinition Height="177" MinHeight="177"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListView Grid.Row="0" BorderBrush="LightGray" BorderThickness="1,1,1,0">
<ListView.View>
<GridView x:Name="SomeName"/>
</ListView.View>
</ListView>
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" ResizeDirection="Rows" BorderBrush="LightGray" BorderThickness="1,0,1,0"/>
<Border Grid.Row="2" Grid.RowSpan="1" BorderBrush="LightGray" BorderThickness="1,0,1,1" Height="Auto" Padding="1">
<ContentControl Grid.RowSpan="1" ContentTemplateSelector="{StaticResource someTemplateSelector}" Content="{Binding itemBinding, Mode=OneWay}" Height="Auto"/>
</Border>
<GridSplitter Grid.Row="3" Height="5" HorizontalAlignment="Stretch" ResizeDirection="Rows" BorderBrush="LightGray" BorderThickness="1,0,1,0"/>
<Button Grid.Row="4" Grid.RowSpan="1" DockPanel.Dock="Right" Margin="3,0,0,0" Command="{Binding Click}" Width="28" Height="28" Padding="0" VerticalAlignment="Bottom">
<Image Width="16" Height="16" Source="{StaticResource Heart}"/>
</Button>
</Grid>
上面的 XAML 是有效的,但边框与下面的所有行重叠,包括第 2 行,而不是一直延伸到下一个 GridSplitter
。
它看起来大致是这样的:
您有五行,但只有三个行定义
添加所需的行定义:
<Grid.RowDefinitions>
<RowDefinition Height="177" MinHeight="177"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
并且布局应该是正确的。