Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to right align text in a DataGrid column header in xaml?

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.

like image 618
user763554 Avatar asked Jan 10 '12 21:01

user763554


1 Answers

Set the HorizontalContentAlignment of the header using the HeaderStyle:

<DataGridTemplateColumn.HeaderStyle>
    <Style TargetType="DataGridColumnHeader">
        <Setter Property="HorizontalContentAlignment" Value="Right"/>
    </Style>
</DataGridTemplateColumn.HeaderStyle>
like image 70
H.B. Avatar answered Sep 18 '22 12:09

H.B.