Skip to content

Commit 093c49c

Browse files
authored
Merge pull request #763 from telerik/new-kb-ribbonbar-custom-button-element-3b1897cca5e74a429f97b19b6c88dcb9
Added new kb article ribbonbar-custom-button-element
2 parents 91957b5 + f0580fa commit 093c49c

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Apply Theming to custom RadButtonElement in RadRibbonBar
3+
description: Learn how to apply consistent themes to derived RadButtonElement instances in RadRibbonBar for UI for WinForms.
4+
type: how-to
5+
page_title: Applying Themes to Custom RadButtonElements in RadRibbonBar
6+
meta_title: Applying Themes to Custom RadButtonElements in RadRibbonBar
7+
slug: ribbonbar-custom-button-element
8+
tags: ribbonbar, radbuttonelement, themes, class-property
9+
res_type: kb
10+
ticketid: 1695130
11+
---
12+
13+
## Environment
14+
15+
|Product Version|Product|Author|
16+
|----|----|----|
17+
|2025.2.520|RadRibbonBar for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)|
18+
19+
## Description
20+
21+
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.
22+
23+
## Solution
24+
25+
Below is an example of how to implement this:
26+
27+
````C#
28+
29+
public class CustomRadButtonElement : RadButtonElement
30+
{
31+
public CustomRadButtonElement()
32+
{
33+
// Set specific Class property values for consistent theming in RadRibbonBar
34+
this.Class = "RibbonBarButtonElement";
35+
this.BorderElement.Class = "ButtonInRibbonBorder";
36+
this.ButtonFillElement.Class = "ButtonInRibbonFill";
37+
}
38+
39+
protected override Type ThemeEffectiveType
40+
{
41+
get
42+
{
43+
return typeof(RadButtonElement);
44+
}
45+
}
46+
}
47+
48+
````
49+
50+
This approach ensures that the `RadRibbonBar` applies the correct themes to the derived button element.
51+
52+
## See Also
53+
54+
* [RadRibbonBar Documentation](https://docs.telerik.com/devtools/winforms/controls/ribbonbar/overview)

0 commit comments

Comments
 (0)