This article demonstrates how to change the style for a specific element state without losing the applied style for the rest of the states.

By default, when you set a certain RadProperty in code, this setting will have a higher priority, called Local, than the setting introduced in the theme, which sets with Style priority (see RadObject). As a result, if you set the BackColor of a button’s FillPrimitive in code, even though the theme defines other colors for other states (hover, pressed), these will not be applied, as the Local setting has higher priority than the Style setting. With the API discussed in this article, you will be able to override the styles defined in the theme, and set the desired property value with priority Style.Hence, the rest of the defined styles in the theme will still work as expected.

Here is an example. By default, RadButton, like most of the visual items in the UI for WinForms suite has hover state coming from the theme.

Consider the case in which you should change the BackColor for a RadButton. To achieve it, you will probably use the following code snippet:

The GetAvailableVisualStates method returns a list of the string representation of the applicable states for this element. These can be used as separate states or combined. When combining, use the dot notation e.g. IsDefault.MouseOver.