Skip to content

Commit 957b50f

Browse files
grizooodtom-englert
authored andcommitted
fix listbox null
1 parent 16703df commit 957b50f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/DataGridExtensions/MultipleChoiceFilter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public override void OnApplyTemplate()
9090
{
9191
base.OnApplyTemplate();
9292

93+
var listBox = _listBox = Template?.FindName("PART_ListBox", this) as ListBox;
94+
if (listBox == null)
95+
return;
96+
listBox.SelectionChanged += ListBox_SelectionChanged;
97+
9398
var filterColumnControl = this.FindAncestorOrSelf<DataGridFilterColumnControl>();
9499

95100
BindingOperations.SetBinding(this, FilterProperty, new Binding { Source = filterColumnControl, Path = new PropertyPath(DataGridFilterColumnControl.FilterProperty) });
@@ -102,18 +107,13 @@ public override void OnApplyTemplate()
102107
var dataGridItems = (INotifyCollectionChanged)dataGrid.Items;
103108
dataGridItems.CollectionChanged += (_, __) => UpdateSourceValuesTarget();
104109

105-
var listBox = _listBox = Template?.FindName("PART_ListBox", this) as ListBox;
106-
if (listBox == null)
107-
return;
108-
109110
var filter = Filter;
110111

111112
if (filter?.Items == null)
112113
{
113114
listBox.SelectAll();
114115
}
115116

116-
listBox.SelectionChanged += ListBox_SelectionChanged;
117117
var items = (INotifyCollectionChanged)listBox.Items;
118118

119119
items.CollectionChanged += ListBox_ItemsCollectionChanged;

0 commit comments

Comments
 (0)