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.
Unfortunately, activation email could not send to your email. Please try again.

GridTreeColumn header style

Thread ID:

Created:

Updated:

Platform:

Replies:

114700 Dec 4,2013 03:58 PM Dec 11,2013 07:46 AM WPF 6
loading
Tags: GridControl
Pavel
Asked On December 4, 2013 03:58 PM

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 08:24 AM

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>

       

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

       <Setter Property="Template">

             <Setter.Value>

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

                    <ContentPresenter Name="PART_ContentPresenter"

                               Content="{TemplateBinding Text}"

                                        ContentTemplate="{TemplateBinding ContentDataTemplate}">

                                                  

                       <ContentPresenter.Resources>

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

                                          BasedOn="{StaticResource WrappingStyle}"/>

                        </ContentPresenter.Resources>  

                         

                    </ContentPresenter>

                </ControlTemplate>

           </Setter.Value>

      </Setter>

</Style>

 

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.

 

Thanks,

Shakul Hameed


Pavel
Replied On December 5, 2013 09:35 AM

Thanks for this answer!

And how can I do autoheight in header row?

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

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.                                                          

 

Thanks,

Shakul Hameed


Pavel
Replied On December 7, 2013 08:25 AM

Thanks very much!
It's works!

Pavel
Replied On December 7, 2013 09:56 AM

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


Jai Ganesh S [Syncfusion]
Replied On December 11, 2013 07:46 AM

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" />

</Style>

 

 

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"

                               HeaderRowHeight="60"

                               ItemsSource="{Binding GridItemSource}"

                               >

 

 

Please let us know if you need further assistance,

 

Thank you,

Jai Ganesh S

 


CONFIRMATION

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.

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.

;