RadDropDownButton Background When IsOpen

3 posts, 0 answers
  1. KWUN WA
    KWUN WA avatar
    17 posts
    Member since:
    Aug 2015

    Posted 08 Jan Link to this post


    Is there any way of changing the background color on a RadDropDownButton when IsOpen = true, without needing to update the template?

  2. Martin Ivanov
    Martin Ivanov avatar
    2135 posts

    Posted 09 Jan Link to this post

    Hello KWUN WA,

    There is no API that allows you to easily change the background of the button when the dropdown is opened. However, if you don't want to extract the template of the button you can use the visual tree helper methods to get the corresponding visual element and set its Background. Here is an example in code:
    private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
        var btn = (RadDropDownButton)sender;
        var checkedVisual = btn.ChildrenOfType<Border>().FirstOrDefault(x => x.Name == "CheckedVisual");
        if (checkedVisual != null)
            checkedVisual.Background = Brushes.Green;
    Note that the Name of the visual might differ across the different Telerik themes. This is why if this doesn't work please peek in the corresponding template and see which element exactly you need.

    Also, the Material, Fluent and Crystal themes expose an attached properties (in the MaterialAssist class) that you can use in order to modify the backgrounds of the controls in the different states. You can read more about this in the corresponding theme article.

    Martin Ivanov
    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.
  3. KWUN WA
    KWUN WA avatar
    17 posts
    Member since:
    Aug 2015

    Posted 09 Jan in reply to Martin Ivanov Link to this post

    Thanks Martin, that worked perfectly.
Back to Top