Inheriting Control makes theme disappear

2 posts, 0 answers
  1. Michael
    Michael avatar
    12 posts
    Member since:
    Jan 2008

    Posted 31 Jul 2009 Link to this post

    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.
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 03 Aug 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top