首页 > 其他 > 详细

DataGrid 字体垂直居中

时间:2020-02-28 19:37:15      阅读:224      评论:0      收藏:0      [点我收藏+]

如果用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>

 

DataGrid 字体垂直居中

原文:https://www.cnblogs.com/iDream2018/p/12378334.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!