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>

 

posted @ 2021-08-20 21:36  晨晞gg  阅读(2803)  评论(1编辑  收藏  举报