Events Overview
Use RadComboBox events to react when the drop-down opens, closes, or the selection changes. This article shows how to subscribe to the most common events and how to use DropDownOpened to reset the drop-down scroll position each time the list opens.
Subscribing to Event
Subscribe to a RadComboBox event in XAML or in code-behind.
Example 1: Subscribe to an event in XAML
<telerik:RadComboBox x:Name="radComboBox" DropDownOpened="RadComboBox_DropDownOpened" />
Example 2: Subscribe to an event in code-behind
this.radComboBox.DropDownOpened += RadComboBox_DropDownOpened;
Events
Start with the following events when you customize RadComboBox behavior:
DropDownOpened
Use DropDownOpened when you need to change the drop-down state after the popup becomes visible. Typical scenarios include loading data on demand, focusing an element in the popup, or resetting the scroll position.
Example 3: Handle the DropDownOpened event
private void RadComboBox_DropDownOpened(object sender, EventArgs e)
{
var radComboBox = (RadComboBox)sender;
}
DropDownClosed
Use DropDownClosed when you need to react after the user dismisses the drop-down. This event is useful when you want to commit UI changes or trigger cleanup logic after the popup closes.
Example 4: Handle the DropDownClosed event
private void RadComboBox_DropDownClosed(object sender, EventArgs e)
{
var radComboBox = (RadComboBox)sender;
}
SelectionChanged
Use SelectionChanged when you need to inspect the selected and unselected items. The SelectionChangedEventArgs type exposes the AddedItems and RemovedItems collections.
Example 5: Handle the SelectionChanged event
private void RadComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var radComboBox = (RadComboBox)sender;
IList selectedItems = e.AddedItems;
IList unselectedItems = e.RemovedItems;
}
SelectionChangedis inherited from the Selector class.
Reset the Drop-Down Scroll Position on Open
By default, RadComboBox keeps the last scroll position when the user closes and reopens the drop-down. This behavior is the same when AllowMultipleSelection is True.
RadComboBoxdoes not expose a built-in property that resets the drop-down list to the first item every time it opens. To enforce that behavior, handleDropDownOpenedand scroll the popupScrollViewerin code.
To reset the drop-down scroll position each time the list opens:
- Subscribe to the
DropDownOpenedevent. - Find the
ScrollViewerinside the popup after the drop-down opens. - Call
ScrollToTop()on thatScrollViewer.
Example 6: Subscribe to DropDownOpened in a multiple-selection combo box
<telerik:RadComboBox x:Name="radComboBox"
AllowMultipleSelection="True"
DropDownOpened="CountriesComboBox_DropDownOpened" />
Example 7: Reset the drop-down scroll position in code-behind
private void CountriesComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is RadComboBox comboBox && comboBox.Items.Count > 1)
{
// VisualTreeHelper cannot cross Popup boundaries because the Popup
// opens in a separate PresentationSource. We find the Popup first,
// then search within popup.Child. The Dispatcher delay ensures the
// popup layout is complete before we try to access its visual tree.
Dispatcher.BeginInvoke(() =>
{
var popup = FindChildElement<Popup>(comboBox);
if (popup?.Child != null)
{
var scrollViewer = FindChildElement<ScrollViewer>(popup.Child);
scrollViewer?.ScrollToTop();
}
}, DispatcherPriority.Loaded);
}
}
private static T FindChildElement<T>(DependencyObject parent) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is T match)
return match;
var result = FindChildElement<T>(child);
if (result != null)
return result;
}
return null;
}
Add the required using directives (for example System.Windows, System.Windows.Controls, System.Windows.Controls.Primitives, System.Windows.Media, and System.Windows.Threading) if they are not already present in the code-behind file.
Because the code runs after DropDownOpened fires, the popup is already created and the ScrollViewer is available to scroll back to the top.