New to Telerik UI for WPF? Download free 30-day trial

Wrap the Text in the Column Header

This article shows how you can wrap the text of the column header, i.e. to have a multi-line text in the header. The end result will look like this:

Wrap Column Header Text in RadGridView - Telerik's WPF DataGrid

Solution 1

As of R2 2016, the columns expose a HeaderTextWrapping property which can be used to set the wrapping of the column header cells.

<telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"  
                            DataFormatString="{}{0:yyyy}" 
                            Width="100" 
                            Header="Stadium Established Date" 
                            HeaderTextWrapping="Wrap" /> 

More information about the headers' text properties which can be set on the columns can be found here.

Solution 2

We will take advantage of the fact that the Header property of the GridView column is of type Object so we can put everything in it. In this case this would be a TextBlock which has a convenient property TextWrapping

<telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"  
                            DataFormatString="{}{0:yyyy}" 
                            Width="100" > 
    <telerik:GridViewDataColumn.Header> 
        <TextBlock Text="Stadium Established Date" TextWrapping="Wrap" /> 
    </telerik:GridViewDataColumn.Header> 
</telerik:GridViewDataColumn> 

Please note that this approach can cause issues if you're binding the header to another control's content, for example, the Content of the CheckBoxes from the example in the Control Panel article. In this case, you need to make sure that you're creating a copy of the TextBlock or use a converter to only access its Text property.

See also

In this article