This is a migrated thread and some comments may be shown as answers.
Override Theme Value for RadButton BorderElement (BorderPrimitive)
3 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 22 Jun 2018, 10:27 PM

The following link has a great example for Button FillPrimitive.

https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time

However, I am having a lot of trouble trying to do the same thing with my RadButton's BorderPrimitive.

The following does not work.

this.radButton1.ButtonElement.SetThemeValueOverride(Telerik.WinControls.Primitives.BorderPrimitive.ForeColorProperty,Color.Red, "", (Telerik.WinControls.Primitives.BorderPrimitive));

What will work? I tried accessing this.radButton1.ButtonElement.BorderElement but there is no SetThemeValueOverride member.

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 25 Jun 2018, 09:51 AM
Hello Stephen,

Thank you for writing.

Please make sure that you are passing the Type of the border primitive as the last parameter of the SetThemeValueOverride method. I also tested a similar setup and I am able to change the border color with the following snippet: 
this.radButton1.ButtonElement.SetThemeValueOverride(Telerik.WinControls.Primitives.BorderPrimitive.ForeColorProperty, Color.Red, "", typeof(Telerik.WinControls.Primitives.BorderPrimitive));
this.radButton1.ButtonElement.SetThemeValueOverride(Telerik.WinControls.Primitives.BorderPrimitive.ForeColorProperty, Color.Red, "IsDefault", typeof(Telerik.WinControls.Primitives.BorderPrimitive));

Please note that the element states are defined in the themes and you can check a particular theme setting for a specific element state in the Visual Style Builder tool: https://docs.telerik.com/devtools/winforms/tools/visual-style-builder/overview

I hope this helps. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stephen
Top achievements
Rank 1
answered on 25 Jun 2018, 05:00 PM

Hi Hristo,

Thank you for confirming that this code should work. The problem was that I had code similar to the following:

this.radButton1.ForeColor = Color.Red;

 

I've encountered this behavior with BackColor as well. It seems that when using Telerik controls, we should be trying to use Telerik's properties as much as possible and stay away from the WinForms properties.

0
Hristo
Telerik team
answered on 26 Jun 2018, 06:15 AM
Hello Stephen,

Thank you for writing back. 

I cannot say that you should avoid the standard or inherited WinForms properties but it depends on what you are trying to achieve. For example, if you set the fore color as in your last code snippet this will change the color of the text in the button for all element states. A value set this way is considered to be local and it has a higher priority than the properties defined in the themes. At the same time, our controls are built internally from light-weight visual elements on top of TPF enabling our theming mechanism to work. The themes work with property values set on the visual elements and not on the control.

As your task is to change the border colors of the buttons for the default state you will need to use the ThemeValueOverride API similarly to my code snippet. The VSB tool will also help when inspecting the available states for a particular element.

I hope this information is useful. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Stephen
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or