WPF DataGrid列未与标题对齐

WPF DataGrid列未与标题对齐,wpf,Wpf,我的WPF DataGrid列未与标题对齐。知道为什么吗 更多信息: 在按钮的默认样式周围添加边距会导致此问题。当我使用该技术(如果找到)以编程方式生成Generic.xaml文件时,出现了此问题 我没有一个默认的保证金,但当我把自动宽度去掉时,问题似乎已经消失了 <!--<Button Command="SelectAll" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=DataGrid, R

我的WPF DataGrid列未与标题对齐。知道为什么吗

更多信息:


在按钮的默认样式周围添加边距会导致此问题。

当我使用该技术(如果找到)以编程方式生成Generic.xaml文件时,出现了此问题

我没有一个默认的保证金,但当我把自动宽度去掉时,问题似乎已经消失了

<!--<Button Command="SelectAll" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=DataGrid, ResourceId=DataGridSelectAllButtonStyle}}" Width="Auto" Visibility="Visible" Focusable="False" />-->
<Button Command="SelectAll" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=DataGrid, ResourceId=DataGridSelectAllButtonStyle}}" Width="5" Visibility="Visible" Focusable="False" />