diff --git a/src/DataGridExtensions/DataGridFilterColumnControl.cs b/src/DataGridExtensions/DataGridFilterColumnControl.cs index 3c4b6c6..3fbc5ad 100644 --- a/src/DataGridExtensions/DataGridFilterColumnControl.cs +++ b/src/DataGridExtensions/DataGridFilterColumnControl.cs @@ -176,7 +176,7 @@ public object? Filter /// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date /// values when the source object changes. /// - public IEnumerable Values => InternalValues().Distinct().ToList().AsReadOnly(); + public IReadOnlyCollection Values => InternalValues().Distinct().ToList().AsReadOnly(); /// /// Returns all distinct source values of this column as string. @@ -186,7 +186,7 @@ public object? Filter /// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date /// values when the source object changes. /// - public IEnumerable SourceValues + public IReadOnlyCollection SourceValues { get { @@ -205,7 +205,7 @@ public IEnumerable SourceValues /// You may need to include "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource to get up-to-date /// values when the source object changes. /// - public IEnumerable SelectableValues + public IReadOnlyCollection SelectableValues { get { diff --git a/src/DataGridExtensions/MultipleChoiceFilter.cs b/src/DataGridExtensions/MultipleChoiceFilter.cs index 9c94c1b..4495c79 100644 --- a/src/DataGridExtensions/MultipleChoiceFilter.cs +++ b/src/DataGridExtensions/MultipleChoiceFilter.cs @@ -65,12 +65,12 @@ public bool HasTextFilter public static readonly DependencyProperty HasTextFilterProperty = DependencyProperty.Register( "HasTextFilter", typeof(bool), typeof(MultipleChoiceFilter), new PropertyMetadata(default(bool))); - private IEnumerable? SourceValues => (IEnumerable?)GetValue(SourceValuesProperty); + private IReadOnlyCollection? SourceValues => (IReadOnlyCollection?)GetValue(SourceValuesProperty); private static readonly DependencyProperty SourceValuesProperty = - DependencyProperty.Register("SourceValues", typeof(IList), typeof(MultipleChoiceFilter), new FrameworkPropertyMetadata(null, (sender, e) => ((MultipleChoiceFilter)sender).SourceValues_Changed((IList)e.NewValue))); + DependencyProperty.Register("SourceValues", typeof(IReadOnlyCollection), typeof(MultipleChoiceFilter), new FrameworkPropertyMetadata(null, (sender, e) => ((MultipleChoiceFilter)sender).SourceValues_Changed((IReadOnlyCollection)e.NewValue))); - private void SourceValues_Changed(IEnumerable? newValue) + private void SourceValues_Changed(IReadOnlyCollection? newValue) { OnSourceValuesChanged(newValue); } @@ -197,12 +197,12 @@ protected virtual MultipleChoiceContentFilter CreateFilter(IEnumerable? /// Called when the source values have changed. /// /// The new value. - protected virtual void OnSourceValuesChanged(IEnumerable? newValue) + protected virtual void OnSourceValuesChanged(IReadOnlyCollection? newValue) { var values = Values; var filterRegex = Filter?.Regex; - if (newValue == null) + if (newValue == null || !newValue.Any()) { values.Clear(); }