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. Image for the cookie policy date
close icon

GridHeaderCellControl override Style basedon

Hey there,

so I'm looking for a way to override the style for a ColumHeader in SfDataGrid while maintain all other properties from the default style.
For regular MS controls, this is quite easy however I struggle to find out how to achieve this with your own controls.

The documentation doesn't really help me with that as the default style is overwritten as it is:
https://help.syncfusion.com/wpf/sfdatagrid/styles-and-templates

Technically I would like to write something like this:

            <Style TargetType="syncfusion:GridHeaderCellControl" x:Key="headerStyle" BasedOn={StaticResource MetroGridHeaderCellControlStyle}">
                <Setter Property="FontSize" Value="20"/>
            </Style>

However this way I'm getting an error that the resource couldn't be resolved. I assume because the ressources are named differently for SF controls.


2 Replies

MS Marcus Scholle November 26, 2016 04:20 PM UTC

Was able to resolve it on my own.

For reference:
In resources

            <DataTemplate x:Key="SfGridDefaultHeader">
                <TextBlock FontSize="26" Foreground="Red" Text="{Binding}"/>
            </DataTemplate>

For the control

             <syncfusion:GridTextColumn HeaderText="Test1" HeaderTemplate="{StaticResource SfGridDefaultHeader}"/>

This leaves all the other functions (Mouseover highlighting e.g.) intact.


SV Srinivasan Vasu Syncfusion Team November 28, 2016 05:24 PM UTC

Hi Marcus, 
 
Thanks for contacting Syncfusion support. 
 
We cannot understand your query clearly. Based on your query we suspect you need to edit the GridHeaderCellControl style with MouseOver states. We prepared a sample on the same and you can download the same from below location. 
 
 
To edit the GridHeaderCellControl complete template please refer link. 
 
 
If you want to load different control other than TextBlock, you can use HeaderTemplate. Please refer the below UG link to refer load DataTemplates. 
 
 
If your requirement doesn’t meet with above solutions, please let us know more details about your requirement. That would more helpful for us to serve you better. 
 
Regards, 
Srinivasan 


Loader.
Live Chat Icon For mobile
Up arrow icon