How do I show a custom button theme while the application theme is also loaded in the visual studio designer?

2 Answers 108 Views
Themes and Visual Style Builder
Benjamin
Top achievements
Rank 1
Iron
Benjamin asked on 04 Apr 2023, 04:57 AM

My application uses a global application wide theme via ThemeResolutionService.

I can view my form, buttons, grids etc in the application theme when using the visual studio designer because I load the application theme in the form constructor.

I have a button that will use a different theme called "RedButton". I can force the button to use the different theme at run time via RadThemeManager using:

myButton.ElementTree.EnableApplicationThemeName = False

myButton.ThemeName = "RedButton"

At runtime, I can see my red button. However; in the visual studio designer, the 'red button' is still using the application theme.

I don't see the ability to disable the application theme on my button in the designer.

How can I get the visual studio designer to show my 'red button' while the application theme is also loaded?

2 Answers, 1 is accepted

Sort by
0
Accepted
Benjamin
Top achievements
Rank 1
Iron
answered on 04 Apr 2023, 07:49 AM

Never mind, I figured it out.

Visual studio designer only respects the RadButton.ElementTree.EnableApplicationThemeName property inside the InitializeComponent() method.

My button inherits RadButton so adding a browsable property allows me to set it via the properties window and therefore gets set inside InitializeComponent.

 <Browsable(True), DefaultValue(True)>
    Public Property EnableApplicationTheme() As Boolean
        Get
            Return ElementTree.EnableApplicationThemeName
        End Get
        Set(value As Boolean)
            ElementTree.EnableApplicationThemeName = value
        End Set
    End Property

Now I can view my form in the designer using the application theme with my button using a custom theme.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Apr 2023, 11:50 AM

Hello, Benjamin,

I am glad that you have found a suitable solution for your scenario.

I would like just to mention that instead of applying a global theme  via the ThemeResolutionService, it is possible to apply a theme to the form (by using the ThemeName property) and then apply it to the ThemeName  property to all controls:

Step 1:

Step 2:

This will iterate the Controls collection and set the control's ThemeName respectively:

Step 3: It is possible to change the ThemeName for a particular control:

It is up to the developer which approach to use in the application according to the complete requirements that should be achieved.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Themes and Visual Style Builder
Asked by
Benjamin
Top achievements
Rank 1
Iron
Answers by
Benjamin
Top achievements
Rank 1
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or