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.

GridHeaderCellControl override Style basedon

Thread ID:

Created:

Updated:

Platform:

Replies:

127595 Nov 26,2016 09:18 AM Nov 28,2016 12:24 PM WPF 2
loading
Tags: SfDataGrid
Marcus Scholle
Asked On November 26, 2016 09:18 AM

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.


Marcus Scholle
Replied On November 26, 2016 11:20 AM

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.

Srinivasan Vasu [Syncfusion]
Replied On November 28, 2016 12:24 PM

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 


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.

;