ToggleButton: custom color settings being applied to all toggle states

2 posts, 0 answers
  1. Nisi
    Nisi avatar
    12 posts
    Member since:
    May 2007

    Posted 04 Mar 2009 Link to this post

    I have two toggle buttons inside a ribbon bar. I have tried to change the orange background the button has when in the 'on' state, but when i do so, it changes it for all states of the button and you can no longer tell which state the button is in.

    What must i do to be able to change the colors of the individual toggle states?
  2. Nikolay
    Nikolay avatar
    1802 posts

    Posted 09 Mar 2009 Link to this post

    Hello Mac & Cheese,

    When you change a color of an element at runtime through the API, this overrides the settings set initially by the theme. Therefore, you lose the colors for the different states.

    In order to achieve the desired scenario, you should change the theme of the RadToggleButtonElement.
    There are two approaches to do this:
    • Make a theme for RadRubbonBar and a theme for RadToggleButton. The ThemeName of both themes should be the same. Then, set the theme of RadRibbonBar to this ThemeName. The style of RadToggleButton element will be changed accordingly.
    • Get the style from a theme made for RadToggleButton and set it to RadToggleButtonElement.

    As you can notice, in both cases you should make a theme for RadToggleButton. This is the correct approach if you want to change a visual property for a state.

    I am attaching a sample project to demonstrate the approach. If you have additional questions, feel free to contact me.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
Back to Top