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

2 posts, 0 answers
  1. Sandor
    Sandor avatar
    15 posts
    Member since:
    Jan 2018

    Posted 11 Feb Link to this post

    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

  2. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 12 Feb Link to this post

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