WPF中DataGrid列标题和列内容居中
<!--列的文本居中--> <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}"> <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" /> </Style>
<!--列的头部标题居中--> <DataGrid.ColumnHeaderStyle> <Style TargetType="DataGridColumnHeader"> <Setter Property="HorizontalContentAlignment" Value="Center"> </Setter> </Style> </DataGrid.ColumnHeaderStyle>