xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

xamarin forms CollectionView Itemssource change Click Bug #14446

Open magic1144 opened 3 years ago

magic1144 commented 3 years ago

image

I use the MVVM pattern.

I click the Go button In ViewModel, the Model.List is changed.

image

After that, the item click in the CollectionView does not work properly

Below is a bug video. What is to be done about this problem? https://user-images.githubusercontent.com/74590063/126623494-7f4214e8-c9f6-4ee8-a79a-b4b8781bf7b4.mp4

logeshpalani30 commented 3 years ago

instead of adding items assign new new observablecollection like below

//Wrong:
foreach(var item in list)
{
Model.List.Add(item);
}
//right:

Model.List = new ObservableCollection(list);
MSicc commented 3 years ago

I just had the same problem.

Switchting to create a new ObservableCollection is a possible workaround, but you might need to manually raise the property change everytime.

This means you can switch to List with property change raise as well...