Override Theme Value for RadButton BorderElement (BorderPrimitive)

4 posts, 0 answers
  1. Stephen
    Stephen avatar
    2 posts
    Member since:
    Apr 2016

    Posted 22 Jun 2018 Link to this post

    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, "", typeof(Telerik.WinControls.Primitives.BorderPrimitive));

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

  2. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 25 Jun 2018 Link to this post

    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.
  3. Stephen
    Stephen avatar
    2 posts
    Member since:
    Apr 2016

    Posted 25 Jun 2018 in reply to Hristo Link to this post

    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.

  4. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 26 Jun 2018 Link to this post

    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.
Back to Top