TextTrimming in ColumnHeader

Nov 23, 2008 at 5:54 PM
Hi all!

How can I add TextTrimming="CharacterEllipsis"  to my ColumnHeaders?

Nov 25, 2008 at 3:12 PM
Hi Cake,

You should be able to do this using the ColumnHeaderStyle property on DataGrid.  You will need to create a Style with TargetType DataGridColumnHeader and set the property in the Style, then assign that Style to ColumnHeaderStyle.

Let me know if you run into any trouble.

Nov 26, 2008 at 2:14 AM
Something like the following should work for you....

        <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
            <Setter Property="ContentTemplate">
                        <TextBlock TextTrimming="CharacterEllipsis"
                                   Text="{Binding Content, RelativeSource={RelativeSource AncestorType={x:Type dg:DataGridColumnHeader}}}">

        <dg:DataGrid ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" ... />