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

RadDropDownButton Background When IsOpen

2 Answers 130 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
KWUN WA
Top achievements
Rank 1
KWUN WA asked on 09 Jan 2019, 01:54 AM

Hi,

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

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 09 Jan 2019, 06:32 AM
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.

Regards,
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.
0
KWUN WA
Top achievements
Rank 1
answered on 09 Jan 2019, 06:53 PM
Thanks Martin, that worked perfectly.
Tags
Buttons
Asked by
KWUN WA
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
KWUN WA
Top achievements
Rank 1
Share this question
or