DataGridColumnHeader alignment

Feb 19, 2009 at 8: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 9:18 AM
Hi xyph,

Try the following:

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

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

Regards,
Colin E.
--
http://www.scottlogic.co.uk/blog/wpf/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples



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

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