This repository has been archived by the owner on May 1, 2024. It is now read-only.
[Bug] [Grid] BindableLayout.ItemsSource bound to ObservableCollection misbehaviors #12929
Labels
Projects
Description
Having the following XAML for a Grid Layout:
where Containers is an
ObservableCollection<ContainerViewModel>
.Having the following ViewModel:
The behavior when pressing the Remove last and Add button is the following:
Which is the expected behavior.
Now, if a rearrangement of the position of the containers in the Grid is done before pressing the Remove Last button (by setting the Grid.Row and Grid.Column to a different value on some of the Containers) things start to get weird. The Container that is removed from the Grid when pressing Remove Last is not anymore the Last element of the Containers ObservableCollection, but the last one to have it's properties set (Row and Column).
See the following example where containers exchange their position (exchanging their Grid.Row and Grid.Column values) when one container is dragged and dropped over another one:
In the first hit of Remove Last Container 3 was the one whose properties were set last, so Container 3 is removed from the view. This is strange because, if a breakpoint is put inside RemoveLast Command, right before Containers.Remove line, the variable removingContainer has Container 4 as the container to be removed (the expected behavior!)
I attach the sample project at the end.
Steps to Reproduce
Expected Behavior
The Containers should be removed in order even when the positions in the view are changed (since they don't change order inside the collection during the process of rearrangement)
Basic Information
Environment
Reproduction Link
GridRearrangeSample.zip
The text was updated successfully, but these errors were encountered: