Using VS2019 and 2022.1.228.40 of Telerik. How do I change both the Hover color and Selected color of the expand button from yellow/dark yellow to colors of my choice?
I found this post that looks like what I want. But when I try the code in the ViewCellFormatting event, I get an error that SignStyle is not a member of GridGroupExpanderCellElement.
Thanks for your help.
I was able to change the selection color with this code:
I tried the same code for "MouseOver" but no luck with that one.
Thank you for the provided details. The mentioned post is really old. May I ask you to share which theme are you using in your application so that I can correctly test it on my side? Also, can you share the full code inside the ViewCellFormatting event handler?
No theme used.
Here's the code:
Thank you for the shared code snippet. I have tested your code and you are right that the mouse hovers effect is not applied. My guess was that the state name was not correct. What I have done to check it is to use our Visual Style Builder to see which state is applied when the mouse is over the button. I see that the state is called HotTracking.
Using this I was able to change the color of the button when the mouse is over it.
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { GridGroupExpanderCellElement expanderCell = e.CellElement as GridGroupExpanderCellElement; if (expanderCell != null) { e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.DarkMagenta, "Selected"); e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, "Selected"); e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.Red, "HotTracking"); e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, "HotTracking"); e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.Aqua, "HierarchyExpanderCell.IsRowSelected.IsCurrentRow.IsPinned.HotTracking"); e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, "HierarchyExpanderCell.IsRowSelected.IsCurrentRow.IsPinned.HotTracking"); } else { e.CellElement.ResetThemeValueOverrides(); } }
The last style is applied when the button is expanded and the mouse is over the button. Here is the result on my side.
Generally speaking, I would suggest using Visual Style Builder to modify our controls and their elements. You could choose a theme and modify the controls per your needs. Then you can apply the custom theme and all controls and their parts inside your application will be customized.