Open skuehlshelby opened 2 years ago
I have using sorting with no issues before. So minimal repro would be helpful.
Do you maybe use WrapLayout? This one is known to has such issue. https://github.com/AvaloniaUI/Avalonia.Controls.ItemsRepeater/issues/6
I am not using WrapLayout. I will try go get a minimal repro, but I might not have time.
I am not using WrapLayout. I will try go get a minimal repro, but I might not have time.
It's up to you. But without a sample, no help can be provided. I hope for your understanding.
Description When using an ItemsRepeater control, the displayed items become out of sync with the items source after the items source is sorted. Display order is not respected, and other weird things can happen as well, including repeated visual elements which are not duplicated in the items source.
To Reproduce The problem has persisted for me under a variety of circumstances. I have tried the following to fix the problem:
Scenario 1: When using ObservableCollection, I sort the items source using only the Move() method.
Scenario 2: When using ObservableCollection, I sort the items source in a temporary copy, then Clear() the items source and Add() from the sorted copy.
Scenario 3: When using a OneWay binding from the items source to ItemsRepeater.Items, I sort the items source in a temporary copy, destroy the original, assign the sorted copy to the items source, and then raise a PropertyChanged event.
CURRENT WORKAROUND: When a sort is completed, I destroy the previous ItemsRepeater and create a new one with the sorted items.
Expected behavior The displayed items should match the source items, in both number and order, at all times.
Desktop
Additional context This is my first project with Avalonia, so please tell me if you think I am doing something incorrectly.