Skip to content

Commit

Permalink
Keep SelectedItemProperty Binding for ClearTextButton in ComboBox
Browse files Browse the repository at this point in the history
Use the SetCurrentValue method to prevent the binding from being released.
  • Loading branch information
unjong authored and punker76 committed Feb 25, 2021
1 parent 8651210 commit 33f45ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,11 @@ public static void ButtonClicked(object sender, RoutedEventArgs e)
{
if (comboBox.IsEditable)
{
comboBox.Text = string.Empty;
comboBox.SetCurrentValue(ComboBox.TextProperty, string.Empty);
comboBox.GetBindingExpression(ComboBox.TextProperty)?.UpdateSource();
}

comboBox.SelectedItem = null;
comboBox.SetCurrentValue(ComboBox.SelectedItemProperty, null);
comboBox.GetBindingExpression(ComboBox.SelectedItemProperty)?.UpdateSource();
}
else if (parent is ColorPickerBase colorPicker)
Expand Down Expand Up @@ -1020,4 +1020,4 @@ private static void ComboBoxLoaded(object sender, RoutedEventArgs e)
}
}
}
}
}

0 comments on commit 33f45ae

Please sign in to comment.