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

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


Set the HorizontalContentAlignment of the header using the HeaderStyle:

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


H.B's answer is correct; just add one more line:

<DataGridTextColumn.HeaderStyle>    <Style TargetType="{x:Type DataGridColumnHeader}">      <Setter Property="HorizontalAlignment" Value="Stretch"/>      <Setter Property="HorizontalContentAlignment" Value="Right"/>    </Style></DataGridTextColumn.HeaderStyle>