Subscribe to SelectionChanged of RadComboBox in RadGridView Column FilteringControl
Environment
Product Version | 2022.3.1109 |
Product | RadGridView for WPF |
Description
How to attach to the SelectionChanged event of the RadComboBox elements hosted in the FilteringControl of RadGridView's GridViewColumn.
Solution
To subscribe to the SelectionChanged event, you can use the EventManager
class in order to subscribe all RadComboBox instances to the event. Then, in the event handler, you can check if the current RadComboBox
is hosted in FilteringControl
. In that case, execute the code in the handler.
public partial class MainWindow : Window
{
static MainWindow()
{
EventManager.RegisterClassHandler(typeof(RadComboBox), RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(OnFilteringControlComboBoxSelectionChanged));
}
private static void OnFilteringControlComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var comboBox = (RadComboBox)sender;
var filteringControl = comboBox.ParentOfType<FilteringControl>();
if (filteringControl != null)
{
// execute the custom selection changed code here
}
}
public MainWindow()
{
InitializeComponent();
}
}