From 7b6a7259bc9386964aaea2ad5950ffa3fff84711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Thu, 23 Apr 2020 17:18:32 +0200 Subject: [PATCH] Bugfix: BindingListCollectionView item replace issue (#1314) --- .../System/Windows/Data/BindingListCollectionView.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs index 2aa61ba0dc1..955cac54d36 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs @@ -2009,6 +2009,18 @@ private void OnListChanged(object sender, ListChangedEventArgs args) break; case ListChangedType.ItemChanged: + // if there is no PropertyDescriptor, then ItemChanged refers to a Replace event + // (IBindingList indexer set) and not a property change of an item + if (args.PropertyDescriptor == null) + { + item = InternalList[index]; + var oldItem = _cachedList[index]; + _cachedList[index] = item; + forwardedArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, oldItem, index); + break; + } + + // here ItemChange refers to a property change if (!_itemsRaisePropertyChanged.HasValue) { // check whether individual items raise PropertyChanged events