Skip to content

Commit bc7307f

Browse files
committed
push selection change events behind text events, so hit proxy can query current state better, fixing issue with hint colouring. #532
1 parent cc6bbb8 commit bc7307f

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

MaterialDesignThemes.Wpf/HintProxyFabric.ComboBox.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ private sealed class ComboBoxHintProxy : IHintProxy
1616
private readonly ComboBox _comboBox;
1717
private readonly TextChangedEventHandler _comboBoxTextChangedEventHandler;
1818

19+
public ComboBoxHintProxy(ComboBox comboBox)
20+
{
21+
if (comboBox == null) throw new ArgumentNullException(nameof(comboBox));
22+
23+
_comboBox = comboBox;
24+
_comboBoxTextChangedEventHandler = ComboBoxTextChanged;
25+
_comboBox.AddHandler(TextBoxBase.TextChangedEvent, _comboBoxTextChangedEventHandler);
26+
_comboBox.SelectionChanged += ComboBoxSelectionChanged;
27+
_comboBox.Loaded += ComboBoxLoaded;
28+
_comboBox.IsVisibleChanged += ComboBoxIsVisibleChanged;
29+
}
30+
1931
public object Content
2032
{
2133
get
@@ -47,21 +59,9 @@ public bool IsEmpty()
4759

4860
public event EventHandler Loaded;
4961

50-
public ComboBoxHintProxy(ComboBox comboBox)
51-
{
52-
if (comboBox == null) throw new ArgumentNullException(nameof(comboBox));
53-
54-
_comboBox = comboBox;
55-
_comboBoxTextChangedEventHandler = new TextChangedEventHandler(ComboBoxTextChanged);
56-
_comboBox.AddHandler(TextBoxBase.TextChangedEvent, _comboBoxTextChangedEventHandler);
57-
_comboBox.SelectionChanged += ComboBoxSelectionChanged;
58-
_comboBox.Loaded += ComboBoxLoaded;
59-
_comboBox.IsVisibleChanged += ComboBoxIsVisibleChanged;
60-
}
61-
6262
private void ComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
6363
{
64-
ContentChanged?.Invoke(sender, EventArgs.Empty);
64+
_comboBox.Dispatcher.InvokeAsync(() => ContentChanged?.Invoke(sender, EventArgs.Empty));
6565
}
6666

6767
private void ComboBoxIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)

MaterialDesignThemes.Wpf/SmartHint.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,18 @@ public object Hint
5252

5353
#region IsContentNullOrEmpty
5454

55-
public static readonly DependencyProperty IsContentNullOrEmptyProperty = DependencyProperty.Register(
56-
nameof(IsContentNullOrEmpty), typeof(bool), typeof(SmartHint), new PropertyMetadata(default(bool)));
55+
private static readonly DependencyPropertyKey IsContentNullOrEmptyPropertyKey =
56+
DependencyProperty.RegisterReadOnly(
57+
"IsContentNullOrEmpty", typeof(bool), typeof(SmartHint),
58+
new PropertyMetadata(default(bool)));
59+
60+
public static readonly DependencyProperty IsContentNullOrEmptyProperty =
61+
IsContentNullOrEmptyPropertyKey.DependencyProperty;
5762

5863
public bool IsContentNullOrEmpty
5964
{
60-
get { return (bool)GetValue(IsContentNullOrEmptyProperty); }
61-
set { SetValue(IsContentNullOrEmptyProperty, value); }
65+
get { return (bool) GetValue(IsContentNullOrEmptyProperty); }
66+
private set { SetValue(IsContentNullOrEmptyPropertyKey, value); }
6267
}
6368

6469
#endregion

0 commit comments

Comments
 (0)