[英]datagridHeader is being smaller when the scrollbar is appearing to fit the data
enter image description here我正在使用这个数据网格,当数据很少时 header 很好,但是当数据行很多时滚动条可见并且 header 行更短,所以即使滚动条在这里? 我的问题图片
<DataGrid Margin="10"
HeadersVisibility="All"
FlowDirection="{StaticResource DirectFlowDirection}"
Foreground="{DynamicResource MainBrush}"
Background="{DynamicResource DataGridBackgroundBrush}"
RenderTransformOrigin="0.5,0.5">
<DataGrid.Resources>
<Style BasedOn="{StaticResource Rows}" TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="datagrid_MouseDoubleClick"/>
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu}"/>
<!--<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>-->
</Style>
<Style TargetType="DataGridRowHeader">
<Setter Property="Width" Value="1*"></Setter>
</Style>
<Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="{DynamicResource DataGridHeaderColor}"/>
<Setter Property="Foreground" Value="{DynamicResource DataGridHeaderForeground}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>MyColumns here</DataGrid.Columns>
我希望 header 行保持整个 window 宽度
在 itemspresenter 周围使用滚动查看器重新模板化看起来是可能的,但您的项目中已经有了样式。
如果您的关注纯粹是装饰性的,您可以考虑在左上角的顶部放置一个蓝色的小矩形来填充该区域。 也许让它 hittestable 为假。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.