From f994ec977be9c84d389b913f4a33a5b277d6e91b Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 24 May 2021 22:34:35 +0800 Subject: [PATCH] fixed a bug of CheckComboBox SelectedItem cannot be restored while clearing --- .../Controls/Input/CheckComboBox/CheckComboBox.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs b/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs index 9b9b0baf..fd8a4796 100644 --- a/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs +++ b/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs @@ -116,7 +116,15 @@ namespace HandyControl.Controls public CheckComboBox() { AddHandler(Controls.Tag.ClosedEvent, new RoutedEventHandler(Tags_OnClosed)); - CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => SelectedItems.Clear())); + + CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => + { + SetCurrentValue(SelectedValueProperty, null); + SetCurrentValue(SelectedItemProperty, null); + SetCurrentValue(SelectedIndexProperty, -1); + SelectedItems.Clear(); + })); + ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged; }