Open Dimigergo opened 2 years ago
Hello Dimigergo, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
Think this is a duplicate of #2913, thanks for providing a minimal repro project @Dimigergo.
Stack:
System.Private.CoreLib.dll!System.ThrowHelper.ThrowArgumentOutOfRange_IndexException() Unknown
Microsoft.Toolkit.Uwp.UI.dll!Microsoft.Toolkit.Uwp.UI.AdvancedCollectionView.this[int].get(int index) Line 214 C#
Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.dll!Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals.DataGridDataConnection.NotifyingDataSource_VectorChanged(Windows.Foundation.Collections.IObservableVector<object> sender, Windows.Foundation.Collections.IVectorChangedEventArgs e) Line 957 C#
Microsoft.Toolkit.Uwp.UI.dll!Microsoft.Toolkit.Uwp.UI.AdvancedCollectionView.OnVectorChanged(Windows.Foundation.Collections.IVectorChangedEventArgs e) Line 65 C#
Microsoft.Toolkit.Uwp.UI.dll!Microsoft.Toolkit.Uwp.UI.AdvancedCollectionView.SourceNcc_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 629 C#
System.ObjectModel.dll!System.Collections.ObjectModel.ObservableCollection<AdvancedCollectionView.MainPage.CValami>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown
AdvancedCollectionView.exe!AdvancedCollectionView.MainPage.ButtonClick(object sender, Windows.UI.Xaml.RoutedEventArgs e) Line 91 C#
So, I think the issue here is DataGrid
is trying to retrieve the item to know which one is removed, but it's already been removed from the collection when the event is called. Normally with an INotifyCollectionChanged
event the item is provided in the event args, but that doesn't seem to be the case with the IVectorChangedEventArgs
If we swap the DataGrid
for a ListView
, things work fine. This seems to work fine in Wpf as they use the collectionchangedevent compared to an observablevector. FYI @RBrid.
Is this issue still open? I getting the same issue with Nuget package CommunityToolkit.WinUI.UI.Controls Version: 7.1.2
Describe the bug
When I use an AdvancedCollectionView and remove the last element from the bound collection the following exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll Index was out of range. Must be non - negative and less than the size of the collection.
Steps to Reproduce
Steps to reproduce the behavior:
Expected behavior
The last element should be deleted without error.
Environment
NuGet Package(s): Package Version(s):
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio version: