New to Telerik UI for WinForms? Download free 30-day trial

Inherit themes from RadControls derivatives

Inherit from a RadControl descendant

When you inherit from a RadControl (or any RadControl descendant), the original control themes are not automatically inherited. The good thing is that this behavior can be overridden very easily by overriding the ThemeClassName property of the descendant of RadControl:


public class RadCustomButton : RadButton  
{ 
    public override string ThemeClassName  
    { 
        get 
        { 
            return typeof(RadButton).FullName;  
        }
    }
}

Public Class RadCustomButton
    Inherits RadButton
    Public Overrides Property ThemeClassName As String
        Get
            Return GetType(RadButton).FullName
        End Get
        Set(value As String)
            MyBase.ThemeClassName = value
        End Set
    End Property
End Class

The example above uses RadButton as a base class. Since the themes depend on the type of the themed class (which is changed when you inherit), using the described override makes base control themes available in the descendant control.

Inherit from a RadElement descendant

When you inherit from a RadElement descendant (for example RadButtonElement), you need to override the ThemeEffectiveType property. This will allow you to have the styling applied to the instance of your custom element class:


public class MyRadButtonElement : RadButtonElement     
{ 
    protected override Type ThemeEffectiveType     
    { 
        get    
        { 
            return typeof(RadButtonElement);     
        }
    }
}

Public Class MyRadButtonElement
Inherits RadButtonElement
    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
        Get
            Return GetType(RadButtonElement)
        End Get
    End Property
End Class

See Also

In this article