This is a migrated thread and some comments may be shown as answers.

Custom GridViewCell Style Not Applying Theme

4 Answers 298 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johnny Chung
Top achievements
Rank 1
Johnny Chung asked on 15 Mar 2018, 07:28 AM

I have an application that is using the Office2013 Implicit theme. 

I need to highlight specific cells in a RadGridView (by changing the background color) and have done so using a custom Style Selector.

The issue is that when the custom GridViewCell style is applied, it does not inherit the Office2013 theme.

 

// CellStyle

<Style x:Key="WarningCellStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
    <Style.Setters>
        <Setter Property="Background" Value="LemonChiffon"/>
        <Setter Property="Foreground" Value="Black"/>
    </Style.Setters>
</Style>

 

Am I targetting the right resources? (TargetType, BasedOn)

Any ideas/suggestions on how to do this otherwise?

Happy to provide more code or screenshots if needed.

 

 

4 Answers, 1 is accepted

Sort by
0
DKO
Top achievements
Rank 1
answered on 15 Mar 2018, 08:35 AM

Hello,

I believe BasedOn should work if your StaticResource has this style set something like this:

 

<telerik:Theme x:Key="DefaultGlobalTheme">Office2013</telerik:Theme>
 
<Style TargetType="{x:Type telerik:GridViewCell}" x:Key="GridViewCellStyle">
        <Setter Property="telerik:StyleManager.Theme" Value="{DynamicResource DefaultGlobalTheme}" />
</Style>

 

Or you could just try and set the theme directly:

<Style x:Key="WarningCellStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
    <Style.Setters>
        <Setter Property="telerik:StyleManager.Theme" Value="Office2013"/>
        <Setter Property="Background" Value="LemonChiffon"/>
        <Setter Property="Foreground" Value="Black"/>
    </Style.Setters>
</Style>
0
Johnny Chung
Top achievements
Rank 1
answered on 16 Mar 2018, 01:23 AM

Thank you for the response, however I wasn't able to get this to work.

I believe the StyleManager doesn't work with Implicit Styles so I tried changing my application to use StyleManager, but that doesn't work either - the theme just isn't applied

 

 

0
Martin Ivanov
Telerik team
answered on 19 Mar 2018, 12:47 PM
Hello Johnny,

I tested your scenario but the theme applies properly. Can you check the attached project and let me know if I am missing something?

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Johnny Chung
Top achievements
Rank 1
answered on 19 Mar 2018, 11:41 PM

Hi Martin. Thank you very much for the sample project.

I noticed that the Office2013 font in the sample matches the font in my highlighted cells - which led me to discover that I had another custom style for the gridviewcell applied further down in the application - a stupid mistake on my part.

 

Thank you all for the help, very much appreciated!

 

 

 

 

Tags
GridView
Asked by
Johnny Chung
Top achievements
Rank 1
Answers by
DKO
Top achievements
Rank 1
Johnny Chung
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or