This is a migrated thread and some comments may be shown as answers.

How can I change background color of list items in MouseOver/Hover state with SetThemeValueOverride

1 Answer 529 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Sandor
Top achievements
Rank 1
Sandor asked on 11 Feb 2019, 01:37 PM

Hi!

Can you please tell me how can I change the background color of dropdown list item with SetThemeValueOverride when the item is in mouseOver state?

And how can I identify the elements, primitives, properties in every case if I need to change something with SetThemeValueOverride? Is there a generic guideline?

Until now I used your Visual Style Builder, but in some specific cases it doesn't help.

e.g.: DropDownList has a ListView, but how can I access ListItems and their states (default, mouseOver, Disabled etc.) through the DropDownList element?

 

Thank you,
Sandor

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 12 Feb 2019, 01:12 PM
Hello Sandor,

The popup with the list element holding the visual items is virtualized and it will be necessary to apply the custom coloring logic in the VisualListItemFormatting event: 
private void RadDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
    args.VisualItem.SetThemeValueOverride(LightVisualElement.NumberOfColorsProperty, 1, "RadListVisualItem.ContainsMouse.MouseOver");
    args.VisualItem.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.LightBlue, "RadListVisualItem.ContainsMouse.MouseOver");
}

Please have in mind that visual states are defined in the themes. The themes can be edited in the Visual Style Builder tool. If you would like to change some value using the ThemeValueOverride API, you can consider checking the theme and the actual name of the visual state.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListControl
Asked by
Sandor
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or