From cefaeeb258b5f48f8a2b436802b71a28b306d599 Mon Sep 17 00:00:00 2001 From: brianboly Date: Tue, 31 Aug 2021 16:39:15 -0400 Subject: [PATCH 1/2] Improving ComboBoxColumn behavior to prevent need to click a ComboBox 3 times for DropDown expansion --- .../DataGrid/DataGridComboBoxColumn.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs index 42f67a40b51..d18d106aa2f 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs @@ -383,7 +383,13 @@ protected override void CancelCellEdit(FrameworkElement editingElement, object u /// The unedited value. protected override object PrepareCellForEdit(FrameworkElement editingElement, RoutedEventArgs editingEventArgs) { - return (editingElement as ComboBox)?.SelectedItem; + var comboBox = editingElement as ComboBox; + if (comboBox != null) + { + comboBox.IsDropDownOpen = true; + } + + return comboBox?.SelectedItem; } /// From 8273bca898fa4ae8e380d560fbaf7cea3eb955f5 Mon Sep 17 00:00:00 2001 From: "Michael Hawker MSFT (XAML Llama)" <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 2 Sep 2021 15:23:11 -0700 Subject: [PATCH 2/2] Update Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs Co-authored-by: Rosario Pulella --- .../DataGrid/DataGridComboBoxColumn.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs index d18d106aa2f..d70e56d0986 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridComboBoxColumn.cs @@ -383,13 +383,13 @@ protected override void CancelCellEdit(FrameworkElement editingElement, object u /// The unedited value. protected override object PrepareCellForEdit(FrameworkElement editingElement, RoutedEventArgs editingEventArgs) { - var comboBox = editingElement as ComboBox; - if (comboBox != null) + if(editingElement is ComboBox comboBox) { comboBox.IsDropDownOpen = true; + return comboBox.SelectedItem; } - return comboBox?.SelectedItem; + return null; } ///