Skip to content

Commit 326a648

Browse files
committed
Fix MultipleChoiceFilter: concurrent filter may lock out each other
1 parent f4de153 commit 326a648

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/DataGridExtensions/DataGridFilterColumnControl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public object? Filter
176176
/// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date
177177
/// values when the source object changes.
178178
/// </remarks>
179-
public IEnumerable<string> Values => InternalValues().Distinct().ToList().AsReadOnly();
179+
public IReadOnlyCollection<string> Values => InternalValues().Distinct().ToList().AsReadOnly();
180180

181181
/// <summary>
182182
/// Returns all distinct source values of this column as string.
@@ -186,7 +186,7 @@ public object? Filter
186186
/// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date
187187
/// values when the source object changes.
188188
/// </remarks>
189-
public IEnumerable<string> SourceValues
189+
public IReadOnlyCollection<string> SourceValues
190190
{
191191
get
192192
{
@@ -205,7 +205,7 @@ public IEnumerable<string> SourceValues
205205
/// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date
206206
/// values when the source object changes.
207207
/// </remarks>
208-
public IEnumerable<string> SelectableValues
208+
public IReadOnlyCollection<string> SelectableValues
209209
{
210210
get
211211
{

src/DataGridExtensions/MultipleChoiceFilter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ public bool HasTextFilter
6565
public static readonly DependencyProperty HasTextFilterProperty = DependencyProperty.Register(
6666
"HasTextFilter", typeof(bool), typeof(MultipleChoiceFilter), new PropertyMetadata(default(bool)));
6767

68-
private IEnumerable<string?>? SourceValues => (IEnumerable<string?>?)GetValue(SourceValuesProperty);
68+
private IReadOnlyCollection<string?>? SourceValues => (IReadOnlyCollection<string?>?)GetValue(SourceValuesProperty);
6969

7070
private static readonly DependencyProperty SourceValuesProperty =
71-
DependencyProperty.Register("SourceValues", typeof(IList<string>), typeof(MultipleChoiceFilter), new FrameworkPropertyMetadata(null, (sender, e) => ((MultipleChoiceFilter)sender).SourceValues_Changed((IList<string>)e.NewValue)));
71+
DependencyProperty.Register("SourceValues", typeof(IReadOnlyCollection<string>), typeof(MultipleChoiceFilter), new FrameworkPropertyMetadata(null, (sender, e) => ((MultipleChoiceFilter)sender).SourceValues_Changed((IReadOnlyCollection<string>)e.NewValue)));
7272

73-
private void SourceValues_Changed(IEnumerable<string?>? newValue)
73+
private void SourceValues_Changed(IReadOnlyCollection<string?>? newValue)
7474
{
7575
OnSourceValuesChanged(newValue);
7676
}
@@ -197,12 +197,12 @@ protected virtual MultipleChoiceContentFilter CreateFilter(IEnumerable<string?>?
197197
/// Called when the source values have changed.
198198
/// </summary>
199199
/// <param name="newValue">The new value.</param>
200-
protected virtual void OnSourceValuesChanged(IEnumerable<string?>? newValue)
200+
protected virtual void OnSourceValuesChanged(IReadOnlyCollection<string?>? newValue)
201201
{
202202
var values = Values;
203203
var filterRegex = Filter?.Regex;
204204

205-
if (newValue == null)
205+
if (newValue == null || !newValue.Any())
206206
{
207207
values.Clear();
208208
}

0 commit comments

Comments
 (0)