From 600a300d902b80e4125c746e94ab53edf62fac4b Mon Sep 17 00:00:00 2001 From: hadashiA Date: Fri, 16 Feb 2024 17:37:57 +0900 Subject: [PATCH] Fix to emit INotifyCollectionChanged.OnPropertyChanged --- sandbox/ConsoleApp/Program.cs | 6 +++--- .../Internal/NotifyCollectionChangedSynchronizedView.cs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sandbox/ConsoleApp/Program.cs b/sandbox/ConsoleApp/Program.cs index 0a55a4c..acc7987 100644 --- a/sandbox/ConsoleApp/Program.cs +++ b/sandbox/ConsoleApp/Program.cs @@ -44,7 +44,7 @@ foreach (var (x, xs) in viewModels) class ViewModel { public int Id { get; set; } - public string Value { get; set; } + public string Value { get; set; } = default!; } class HogeFilter : ISynchronizedViewFilter @@ -65,8 +65,8 @@ class HogeFilter : ISynchronizedViewFilter } public void OnCollectionChanged( - ChangedKind changedKind, - int value, + ChangedKind changedKind, + int value, ViewModel view, in NotifyCollectionChangedEventArgs eventArgs) { diff --git a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs index b496115..522c62f 100644 --- a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs +++ b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs @@ -66,9 +66,11 @@ namespace ObservableCollections.Internal { case ChangedKind.Add: CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, view, eventArgs.NewStartingIndex)); + PropertyChanged?.Invoke(this, CountPropertyChangedEventArgs); return; case ChangedKind.Remove: CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, view, eventArgs.OldStartingIndex)); + PropertyChanged?.Invoke(this, CountPropertyChangedEventArgs); break; case ChangedKind.Move: CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, view, eventArgs.NewStartingIndex, eventArgs.OldStartingIndex));