From b0bc7c21515e000154bd64da3494d0c0bd04544e Mon Sep 17 00:00:00 2001 From: neuecc Date: Tue, 10 Sep 2024 01:07:15 +0900 Subject: [PATCH] fix ArgumentOutOfRangeException when using ToNotifyCollectionChanged with ObservableDictionary #70 --- src/ObservableCollections/SynchronizedViewList.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ObservableCollections/SynchronizedViewList.cs b/src/ObservableCollections/SynchronizedViewList.cs index fedec6c..f1dc3a5 100644 --- a/src/ObservableCollections/SynchronizedViewList.cs +++ b/src/ObservableCollections/SynchronizedViewList.cs @@ -259,7 +259,14 @@ private void Parent_ViewChanged(in SynchronizedViewChangedEventArgs e) case NotifyCollectionChangedAction.Add: // Add or Insert if (e.IsSingleItem) { - listView.Insert(e.NewStartingIndex, e.NewItem.View); + if (e.NewStartingIndex == -1) + { + listView.Add(e.NewItem.View); + } + else + { + listView.Insert(e.NewStartingIndex, e.NewItem.View); + } } else {