CommunityToolkit / CommunityToolkit/Windows
AdvancedCollectionView: sorting behavior is not correct
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
```
class Video
{
public int id;
public (int, uint, int, int, int, uint) SortValue { get; set; }
}
ObservableCollection _screenCollection = new();
AdvancedCollectionView AdvancedCollectionView = new AdvancedCollectionView(_screenCollection);
AdvancedCollectionView.SortDescriptions.Add(new SortDescription("SortValue", SortDirection.Ascending));
for(int i=1; i< 25; i++)
_screenCollection.Add(new Video { SortValue = (1, 5, 0, 0, 0, 0), id=i });
//Order is 3,5,7...
AdvancedCollectionView.RefreshSorting();
//Order is 3,4,6
AdvancedCollectionView.RefreshSorting();
//Order is 3,5,7
```
1. SortValue is same, so I expect the order is same with original collection -> 1,2,3,4,...
2. Why each time calling RefreshSorting(), the order is different.
So in UI, if one field of Video change and call RefreshSorting, instead of just change that video's order, It changes a lot of other videos.
### Regression
_No response_
### Reproducible in sample app?
- [ ] This bug can be reproduced in the sample app.
### Steps to reproduce
```text
Run above code
```
### Expected behavior
Sorting should sort which has value changed.
### Screenshots
_No response_
### Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)
### Other Windows Build number
_No response_
### App minimum and target SDK version
- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [ ] Windows 10, version 2004 (Build 19041)
- [ ] Other (specify)
### Other SDK version
_No response_
### Visual Studio Version
_No response_
### Visual Studio Build Number
_No response_
### Device form factor
_No response_
### Nuget packages
_No response_
### Additional context
_No response_
### Help us help you
Yes, I'd like to be assigned to work on this item.
Contributor guide
Assessment
This issue has not been assessed yet.