如果用DataGridTextColumn作为DataGrid的列,字体垂直居中需要这样设置:

<Style x:Key="Body_Content_DataGrid_Centering"
     TargetType="{x:Type DataGridCell}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridCell}">
                <Grid Background="{TemplateBinding Background}">
                    <ContentPresenter VerticalAlignment="Center" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

标题水平居中这样设置:

<Style TargetType="DataGridColumnHeader">
       <Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-01-09
  • 2021-11-15
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案