Description
I'm submitting a...
Bug report (I searched for similar issues and did not find one)
Current behavior
When I apply a filter to an AdvancedCollectionView that's bound to a DataGrid I am met with an ArgumentOutOfRangeException if the last item was filtered off the list.
The application of the filter eventually causes "public object this[int index]" to try to access a position that is 1 more than the upper bound of the list which throws the ArgumentOutOfRangeException. This occurs when the last item in the list is filtered off. If the last item is not filtered off, no exception occurs.
// GetVariable returns either the requested variable or a blank string, never null.
string username = Utilities.GetVariable("Character");
TriggerList.Filter = x => (((Trigger)x).Character == "" || ((Trigger)x).Character == username);
When an item is filtered out in the last position, it is removed and then "VectorChanged?.Invoke" is called but it's passing the index for the position that no longer exists that is no one above the upper bound. As a test, I modified the "public object this[int index]" to check the upper bound of the "_view" first and not access it if the index was too high (I returned a null if that was the case). This fixed the behavior and allowed the filter to work as far as I can see in my limited testing for my limited use cases.
Expected behavior
You should be able to set a filter with valid syntax / data and not have it throw an exception.
Minimal reproduction of the problem with instructions
1.) Create an AdvancedCollectionView and populate it with test data.
2.) Apply a filter that will remove the last item in the list.
Environment
Nuget Package(s):
Package Version(s):
Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] Insider Build (build number: )
App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] Insider Build (xxxxx)
Device form factor:
- [x] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT
Visual Studio
- [x] 2019 (version: 16.0.0)