DataGridColumnHeader alignment

Feb 19, 2009 at 9:26 AM
How do I change the text-alignment of a header in the DataGrid? Is there any way besides creating a whole new ControlTemplate? I do not wish to lose any existing functionality, such as automatic columnwidth.
Feb 19, 2009 at 10:18 AM
Hi xyph,

Try the following:

<Style x:Key="HeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
    <Setter Property="HorizontalContentAlignment" Value="Right"/>

Setting your DataGrid.ColumnHeaderStyle to this style will right align the header text.

Colin E.
-- - my WPF blog - WPF DataGrid Practical Examples

Feb 19, 2009 at 10:30 AM
Hi Colin!

That did the trick! Thank you very much for the fast reply! It was easier than I thought :-)