How to open DropDown Popup of the GridMultiColumnDropDownList while entering the text in WPF DataGrid?
In WPF DataGrid (SfDataGrid), the WPF MultiColumnDropDownControl (SfMultiColumnDropDownControl) is loaded as
a UIElement in the edit mode
for GridMultiColumnDropDownList. The popup
of the GridMultiColumnDropDownList column is opened
by clicking the drop-down icon of that column, by
default.
You can also open the Popup while entering the
text in the corresponding cell that gets
into the edit mode by enabling
the AllowImmediatePopup and IsDropDownOpen properties. For
this, you need to derive a new class
from the GridCellMultiColumnDropDownRenderer and override
its OnEditElementLoaded virtual method.
public class GridCellMultiColumnDropDownRendererExt : GridCellMultiColumnDropDownRenderer
{
protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
{
//Enables the AllowImmediatePopup and IsDropDownOpen when set to true.
(sender as SfMultiColumnDropDownControl).AllowImmediatePopup = true;
(sender as SfMultiColumnDropDownControl).IsDropDownOpen = true;
//Assigns the input text to the SfMultiColumnDropDownControl's text property.
(sender as SfMultiColumnDropDownControl).Text = PreviewInputText;
base.OnEditElementLoaded(sender, e);
}
}
Note: The above code is only applicable for the WPF platform. For WinRT, refer to the attached sample.
Refer to the following code example to remove the default GridCellMultiColumnDropDownRenderer and add the above customized GridCellMultiColumnDropDownRendererExt to the renderer’s collection in the DataGrid.
public MainWindow()
{
InitializeComponent();
// Adds Custom MultiColumnDropDown renderer to the CellRenderers.
this.grid.CellRenderers.Remove("MultiColumnDropDown");
this.grid.CellRenderers.Add("MultiColumnDropDown", new GridCellMultiColumnDropDownRendererExt());
}
Sample Links:
Conclusion
I hope you enjoyed learning about how to open DropDown Popup of the GridMultiColumnDropDownList while entering the text.
You can refer to our WPF DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF DataGrid example to understand how to create and manipulate data.