Open nicop85 opened 7 months ago
Can repro this issue at android/Windows platforms on the latest 17.10 Preview 5 (8.0.21/8.0.7).
/similarissues
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
None of those similar issues seems to be related to this one
Description
Think of a scenario where you have a list of persons and you want yo pin/unpin some of them as your favorites. You will have a CollectionView with it's ItemSource set to an ObservableCollection of persons. Each one of this persons will have a name and a boolean flag to know if they are favorite or not. Then, in the ItemTemplate, each row will display the name of the person and a button to pin/unpin them as favorite.
The idea is that when the user click the button to pin/unpin a person, it will change the status of the isFavorite flag and it should update the list to show all the favorite persons first and then the rest of them. A very common use case scenario of a list with some kind of preference in the items.
The logic behind the scenes, is that when a user clicks the button to pin/unpin a person, it will first change the IsFavorite flag of that person and then execute a method that performs an ObservableCollection.Clear() and then re fill it again with the updated persons.
The problem I've found is that the update in the item flag is performed well, but the Iist itself doesn't get reorder the right way showing the favorite ones first. This seems to only occur when the update was triggered by an item of the list, because if I put a button to refresh the list and execute the same code to re fill the ObservableCollection, everything works as expected.
Am I missing something or did I make any mistake in the code? Or is it a bug in the CollectionView?
I have tested this in all the 8.0.x versions of MAUI and even in some of 7.0.x, so I guess is something that was there for quite a while or perhaps I'm doing something wrong.
Any advice, please let me know
Steps to Reproduce
Link to public reproduction project repository
https://github.com/nicop85/TestCollectionViewRefresh.git
Version with bug
8.0.21 SR4.1
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Android 11 and up, Windows 10.0.17763.0 and up
Did you find any workaround?
Not yet
Relevant log output
No response