Skip to content

Commit b062ab8

Browse files
author
KB Bot
committed
Added new kb article ribbonbar-custom-button-element
1 parent 7697ab4 commit b062ab8

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: Theming Derived RadButtonElement Instances 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|RadGridView 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)