This project is read-only.

Change font to ColumnHeader on DataGrid


The ColumnHeader doesnt take in count the FontFamily property when changed it in the style


JLuisEstrada wrote Mar 7, 2012 at 10:44 PM

Thats a bug with the DataGridColumnHeader when you set text as a content, it automatically converts it to a TextBlock and the runtime autimatically takes the default style for the TextBlock.

I solved that replacing the ContentPresenter with a TextBlock (in the DataGridColumnHeaderStyle)

<TextBlock Text="{TemplateBinding Content}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            RenderOptions.ClearTypeHint="Enabled" OverridesDefaultStyle="True"
                                            FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}"/>
and works like a charm.

The drawback is that the Header contet should be only text. Fails when you put images ur other controls as content

wrote Feb 14, 2013 at 3:47 AM

wrote Sat at 1:21 AM