DataGrid表头一直无法居中显示,不知如何调整,望各位大牛指点。
我用的样式是Toolkit中的样式文件其中用到控件模板!
<Style TargetType="dataPrimitives:DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="dataPrimitives:DataGridColumnHeader">
<Grid x:Name="Root" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<vsm:VisualStateManager.VisualStateGroups>
........
</vsm:VisualStateManager.VisualStateGroups>
<Rectangle x:Name="BackgroundGradient" Grid.ColumnSpan="3" Stretch="Fill" Fill="{StaticResource GridHeaderBackground}" /> <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}" Cursor="{TemplateBinding Cursor}"/>
.......
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
红色字体标注的是表头的背景色,但是不管我怎么弄,表头就是不居中显示!
------解决方案--------------------------------------------------------