We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridTreeColumn header style

Thread ID:





114700 Dec 4,2013 08:58 PM UTC Dec 11,2013 12:46 PM UTC WPF 6
Tags: GridControl
Asked On December 4, 2013 08:58 PM UTC

How I can set default header style in GridTreeColumn? 
I need set wrap mode = "Wrap" and text alignment

Shakul Hameed M [Syncfusion]
Replied On December 5, 2013 01:24 PM UTC

Hi Pavel,


Thanks for contacting Syncfusion.


We have analyzed your query and we can achieve your requirement by writing styles to GridTreeHeaderCellControl.

Please refer the following code snippet.


Code Snippet:

<Style TargetType="{x:Type TextBlock}" x:Key="WrappingStyle">

            <Setter Property="TextWrapping" Value="Wrap"/>



<Style TargetType="{x:Type syncfusion:GridTreeHeaderCellControl}">

       <Setter Property="Template">


                <ControlTemplate TargetType="{x:Type syncfusion:GridTreeHeaderCellControl}">

                    <ContentPresenter Name="PART_ContentPresenter"

                               Content="{TemplateBinding Text}"

                                        ContentTemplate="{TemplateBinding ContentDataTemplate}">



                                <Style TargetType="{x:Type TextBlock}"

                                          BasedOn="{StaticResource WrappingStyle}"/>









In this, I have written the styles for GridTreeHeaderCellControl. And PART_ContentPresenter is the one, which is used as the ContentPresenter for displaying the text of the GridTreeHeaderCell.

And here, we have written the wrapping style.


We have prepared the sample based on your requirement and you can find the sample from below location.


Sample: GridTreeStyle with WrapText.zip


Please let us know, if you have any concerns.



Shakul Hameed

Replied On December 5, 2013 02:35 PM UTC

Thanks for this answer!

And how can I do autoheight in header row?

Shakul Hameed M [Syncfusion]
Replied On December 6, 2013 09:26 AM UTC

Hi Pavel,


We have analyzed your query and we can achieve your requirement by using the ResizeRowsToFit() method like in the below code snippet.

The ResizeRowsToFit method changes the height of the rows (Make the rows to fit) based on the cell value.


Code snippet:

void ColumnWidths_LineSizeChanged(object sender, Syncfusion.Windows.Controls.Scroll.RangeChangedEventArgs e)


         this.treeGrid.Model.ResizeRowsToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.ResizeCoveredCells);         



We have prepared a sample based on your requirement. In this we have called the ResizeRowsToFit method whenever the Column resized by listening the ColumnWidths_LineSizeChanged event.

Please find the sample from the below location.


Sample: GridTree with Auto Header style.zip


Please let us know, if you have any concerns.                                                          



Shakul Hameed

Replied On December 7, 2013 01:25 PM UTC

Thanks very much!
It's works!

Replied On December 7, 2013 02:56 PM UTC

One question more..)
Can I take same functional in SfDataGrid control?
It is very important!

Jai Ganesh S [Syncfusion]
Replied On December 11, 2013 12:46 PM UTC

Hi Pavel,


We have analyzed your query. Please find the response for your query in SfDataGrid as below:


Query 1:


You can set the Styles for HeaderCell in SfDataGrid by writing the styles for  GridHeaderCellControl. Please find the following code snippet to illustrate this:


Code Snippet [ Xaml]:



<Style TargetType="syncfusion:GridHeaderCellControl">

      <Setter Property="Background" Value="Blue" />

      <Setter Property="Foreground" Value="Gray" />




Query 2:


As of now, we don’t have the functionality to set the Header Row height as “Auto” in SfDataGrid. However, you can set the HeaderRow Height in SfDataGrid by using the “HeaderRowHeight” API. Please find the following code snippet to illustrate this:


CodeSnippet [ XAML]:



<syncfusion:SfDataGrid x:Name="datagrid"


                               ItemsSource="{Binding GridItemSource}"




Please let us know if you need further assistance,


Thank you,

Jai Ganesh S



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon