Apply Theming to custom RadButtonElement in RadRibbonBar
Environment
Product Version | Product | Author |
---|---|---|
2025.2.520 | RadRibbonBar for WinForms | Dinko Krastev |
Description
The RadRibbonBar applies themes based on specific Class property values set on its button elements and their key visual children. So, in order to use an extended RadButtonElement instance in RadRibbonBar, you should set the Class property of the elements that build the look of the button. This way, the custom button will be styled the same as the default buttons in RadRibbonBar control.
Solution
Below is an example of how to implement this:
public class CustomRadButtonElement : RadButtonElement
{
public CustomRadButtonElement()
{
// Set specific Class property values for consistent theming in RadRibbonBar
this.Class = "RibbonBarButtonElement";
this.BorderElement.Class = "ButtonInRibbonBorder";
this.ButtonFillElement.Class = "ButtonInRibbonFill";
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadButtonElement);
}
}
}
This approach ensures that the RadRibbonBar
applies the correct themes to the derived button element.