New to Telerik UI for WPF? Download free 30-day trial

Return Focus to RadMultiColumnComboBox After its Drop Down Closes

Environment

Product Version 2019.3.917
Product RadMultiColumnComboBox for WPF

Description

How to return the focus to RadMultiColumnComboBox after the Popup with its drop down content closes.

Solution

To do this, you can subscribe to the DropDownClosed event of the control and in the event handler manually focus the text input control.

public MainWindow() 
{ 
    InitializeComponent(); 
    this.radMultiColumnComboBox.AddHandler(RadDropDownButton.DropDownClosedEvent, new RoutedEventHandler(OnMCCBDropDownClosed)); 
} 
 
private void OnMCCBDropDownClosed(object sender, RoutedEventArgs e) 
{ 
    var mccb = (RadMultiColumnComboBox)sender; 
    mccb.ChildrenOfType<RadWatermarkTextBox>().First().Focus(); 
} 
If you use the GridViewMultiColumnComboBoxColumn, you can use the PreparedCellForEdit event of RadGridView in order to get the RadMultiColumnComboBox instance and attach the DropDownClosed event handler.

private void RadGridView_PreparedCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e) 
{ 
    var mccb = e.EditingElement as RadMultiColumnComboBox; 
    if (mccb ! null) 
    { 
        mccb.AddHandler(RadDropDownButton.DropDownClosedEvent, new RoutedEventHandler(OnMCCBDropDownClosed)); 
    }        
} 
 
private void OnMCCBDropDownClosed(object sender, RoutedEventArgs e) 
{ 
    var mccb = (RadMultiColumnComboBox)sender; 
    mccb.ChildrenOfType<RadWatermarkTextBox>().First().Focus(); 
} 
In this article