WPF Datagrid 控制 第一行和第一列之间的空白

2021-01-23 03:13

阅读:540

标签:复制   bar   blog   http   title   tst   ring   def   off   

原文:WPF Datagrid 控制 第一行和第一列之间的空白

这个位置就是 这里

技术图片

我们更改 DataGridControltemplate 模板

看树形结构 里面是一个BUtton

功能是全选 能找到了 那就直接改掉就可以

 

  1. "DataGridControlTemplate1" TargetType="{x:Type DataGrid}">
  2. "{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
  3. "DG_ScrollViewer" Focusable="False">
  4. "{x:Type ScrollViewer}">
  5. "Auto"/>
  6. "*"/>
  7. "Auto"/>
  8. "Auto"/>
  9. "*"/>
  10. "Auto"/>
  11. "HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}">
  12. All
  13. "PART_ColumnHeadersPresenter" Grid.Column="1">
  14. "HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}">
  15. Column
  16. "PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" Grid.ColumnSpan="2" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Grid.Row="1"/>
  17. "PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
  18. "1" Grid.Row="2">
  19. "{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}}"/>
  20. "*"/>
  21. "PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
  22. "{TemplateBinding SnapsToDevicePixels}"/>

 

改这个就可以

  1. "HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}">
  2. All

技术图片

WPF Datagrid 控制 第一行和第一列之间的空白

标签:复制   bar   blog   http   title   tst   ring   def   off   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12075413.html


评论


亲,登录后才可以留言!