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

Inheriting Control makes theme disappear

1 Answer 119 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 31 Jul 2009, 07:46 PM
I'm using Telerik Q2 and the OfficeBlue theme as my common theme for all of my controls as I'm using the RadRibbonBar with an Office 2k7 look and feel.

I attempted to extend the RadCheckBox control to implement a 3 state system the way I wanted to using the control as the base.  The problem was, when I added the new inherited control to the form, the theme was gone and I could not find a way to add it back.

The same issue is cauing havok for me especially with the Telerik CAB Enabling Kit.  I'm relying on using the RadTabStrip in my application, however the RadTabWorkspace needed for cab inherits from the RadTabStrip, and the same issue occurs, there's no theme on the control.  The tabs are ugly and in boxes.   Clicking on a tab has no VISUAL effect, even though the tab page switches.  It's impossible to tell the selected tab.

Is there any way to dynamically force a theme on a control at runtime or to have inherited controls inherit the themes as well?

Thanks,

Michael Gerety.

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 03 Aug 2009, 02:16 PM
Hello Michael,

Thanks for contacting us and for the provided details. Our theming mechanism works generally by matching the property settings defined in an XML theme with the type of the elements and the parent control in which they reside.

When you inherit a RadControl, say a RadCheckBox, and use it in your application, the theming mechanism only knows the RadCheckBox type and thus the theme will not be applied.

However, there is an easy way to fix that by overriding ThemeClassName property and returning the class name of the base RadCheckBox control:

public override string ThemeClassName 
     get 
     { 
          return "Telerik.WinControls.UI.RadCheckBox"
     } 
     set 
     { 
          base.ThemeClassName = value; 
     } 

You can place this property override in your inheriting class. You should also override this property in all classes which inherit from Telerik RadControls in order to prevent them from loosing their theme.

For example, for the RadTabStrip control you should use:

public override string ThemeClassName 
     get 
     { 
          return "Telerik.WinControls.UI.RadTabStrip"
     } 
     set 
     { 
          base.ThemeClassName = value; 
     } 


I hope this is helpful. Do not hesitate to write back if you need further assistance.

All the best,
Deyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Themes and Visual Style Builder
Asked by
Michael
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or