From d8b0d8f117b9a2fa5c95b2e559acea1316fb6e7e Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 26 Aug 2024 18:28:11 +0900 Subject: [PATCH 1/2] Add INotifyCollectionChangedSynchronizedView.Refresh() --- src/ObservableCollections/IObservableCollection.cs | 1 + .../Internal/NotifyCollectionChangedSynchronizedView.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/ObservableCollections/IObservableCollection.cs b/src/ObservableCollections/IObservableCollection.cs index 474bb8e..eab69ff 100644 --- a/src/ObservableCollections/IObservableCollection.cs +++ b/src/ObservableCollections/IObservableCollection.cs @@ -59,6 +59,7 @@ namespace ObservableCollections public interface INotifyCollectionChangedSynchronizedView : IReadOnlyCollection, INotifyCollectionChanged, INotifyPropertyChanged, IDisposable { + void Refresh(); } public static class ObservableCollectionsExtensions diff --git a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs index d28aea7..38b8e3e 100644 --- a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs +++ b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs @@ -131,6 +131,11 @@ namespace ObservableCollections.Internal self.PropertyChanged?.Invoke(self, CountPropertyChangedEventArgs); } } + + public void Refresh() + { + OnCollectionChanged(new SynchronizedViewChangedEventArgs(NotifyCollectionChangedAction.Reset)); + } } internal class ListNotifyCollectionChangedSynchronizedView From cb0cf8b38699d92bba1e0d96cc677afb2eb69180 Mon Sep 17 00:00:00 2001 From: zero Date: Tue, 27 Aug 2024 23:20:00 +0900 Subject: [PATCH 2/2] Fix #58 IsCompatibleObject --- .../Internal/NotifyCollectionChangedSynchronizedView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs index d28aea7..ae32b81 100644 --- a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs +++ b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs @@ -169,7 +169,7 @@ namespace ObservableCollections.Internal static bool IsCompatibleObject(object? value) { - return (value is T) || (value == null && default(T) == null); + return (value is TView) || (value is T) || (value == null && default(T) == null); } public bool IsReadOnly => true;