如何右对齐在XAML DataGrid中列标题的文本? [英] How to right align text in a DataGrid column header in xaml?

查看:223
本文介绍了如何右对齐在XAML DataGrid中列标题的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF DataGrid中列标题如下:

 < D​​ataGridTemplateColumn标题=长度WIDTH =100>
     ...
< / DataGridTemplateColumn>
 

我怎么做这个头右对齐?谢谢。我知道如何对齐列的内容。重点是调整列标题。

<=h2_linDIV class>的解决方案

设置 Horizo​​ntalContentAlignment 使用标头中的 HeaderStyle

 &LT; D​​ataGridTemplateColumn.HeaderStyle&GT;
    &LT;风格的TargetType =DataGridColumnHeader&GT;
        &LT; setter属性=Horizo​​ntalContentAlignmentVALUE =右/&GT;
    &LT; /样式和GT;
&LT; /DataGridTemplateColumn.HeaderStyle>
 

I have a WPF DataGrid with a column header as follows:

<DataGridTemplateColumn Header="Length" Width="100">
     ...
</DataGridTemplateColumn>

How do I make this header align right? Thanks. I know how to align the column content. Emphasis is aligning COLUMN HEADER.

解决方案

Set the HorizontalContentAlignment of the header using the HeaderStyle:

<DataGridTemplateColumn.HeaderStyle>
    <Style TargetType="DataGridColumnHeader">
        <Setter Property="HorizontalContentAlignment" Value="Right"/>
    </Style>
</DataGridTemplateColumn.HeaderStyle>

这篇关于如何右对齐在XAML DataGrid中列标题的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆