Subclassing RadTabStrip loses theme

Thread is closed for posting
2 posts, 1 answers
  1. Michael
    Michael avatar
    33 posts
    Member since:
    Mar 2009

    Posted 13 Apr 2009 Link to this post

    Hello -

    If I subclass RadTabStrip, I find that I lose the default theme.  Here is the code:

            public class Tabs : RadTabStrip 
            void Form1_Load(object sender, EventArgs e) 
                var tabs = new RadTabStrip(); 
                tabs.Dock = DockStyle.Fill; 
                tabs.Items.Add(new TabItem() { Text = "First" }); 
                tabs.Items.Add(new TabItem() { Text = "Second" }); 
                tabs.Items.Add(new TabItem() { Text = "Third" }); 

    The above works great & is themed with the default Telerik theme.  However, if I replace "new RadTabStrip()" above with "new Tabs()", the default theme is lost.  For RadElement subclasses, I was told to override ThemeEffectiveType and return the base Telerik type, which works quite nicely.  However, being a Control rather than a RadElement, RadTabStrip doesn't support this virtual method.  I'm guessing there is some other simple way for my subclass to not get in the way of the theme mechanism.

    - Mike
  2. Answer
    Victor avatar
    1358 posts

    Posted 14 Apr 2009 Link to this post

    Hi Michael,

    Thank you for writing. You are correct, overriding the ThemeEffectiveType property applies to RadElement, however you need ThemeClassName property for RadControl. You need to override it and return the type of RadTabStrip.

    Here is a code snippet:

    namespace WindowsFormsApplication5  
        class Tabs : RadTabStrip  
            public override string ThemeClassName  
                    return typeof(RadTabStrip).FullName;  
                    base.ThemeClassName = value;  
    And here is the form constructor:
    namespace WindowsFormsApplication5  
        public partial class Form1 : Form  
            public Form1()  
                Tabs tabControl = new Tabs();  
                tabControl.Size = new Size(300, 300);  
                tabControl.Items.Add(new TabItem("Tab1"));  
                tabControl.Items.Add(new TabItem("Tab2"));  
                tabControl.Items.Add(new TabItem("Tab3"));  
                tabControl.ThemeName = "ControlDefault";  

    Please write back if you need further assistance.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top