定义样式style:dgCell
<Window.Resources>
<XmlDataProvider x:Key="AllItem" />
<Style x:Key="dgCell" TargetType="{x:Type TextBlock}">
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</Window.Resources>
引用样式style:dgCell
<controls:DataGridTextColumn Header="序号" Width="40" Binding="{Binding XPath=@id}" ElementStyle="{StaticResource ResourceKey=dgCell}" />
运行效果