[UWP] NotifyCollectionChangedAction.Add behaves differently while working with custom ObservableCollection #7993
Labels
appModel-UWP
Exclusive to WinUI 2 UWP apps
bug
Something isn't working
needs-author-feedback
Asked author to supply more information.
needs-repro
needs-triage
Issue needs to be triaged by the area owners
team-Controls
Issue for the Controls team
Describe the bug
Exception throws when using AddRange() for custom observable collection and using OnCollectionChanged as below:
Same scenario works fine when OnCollectionChanged was used as below:
Created a custom class based on Observable Collection and declare a method "AddRange()" as below .
Code used in Model:
Code Used in ViewModel
Code used in Main Page:
Code Behind:
Why does OnCollectionChanged with NotifyCollectionChangedAction.Reset as parameter has to be raised for Adding items in the collection?
Note: Sample works fine when OnCollectionChanged() raised with NotifyCollectionChangedAction.Add, addedItems and starting index as parameter.
Exception occurs only when using the OnCollectionChanged with NotifyCollectionChangedAction.Add and addedItems.
Steps to reproduce the bug
Expected behavior
Exception should not be thrown, items should be properly added in the collection.
Screenshots
Exception Image:
![image](https://user-images.githubusercontent.com/92511047/205988563-72f7eee6-4527-464c-836b-2b1c8f8e4d24.png)
NuGet package version
None
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response
The text was updated successfully, but these errors were encountered: