xamarin / Xamarin.Forms

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

[Bug] Listview on wpf takes takes a lot to clear when changing itemsource #8053

Closed observer1 closed 1 year ago

observer1 commented 4 years ago

Description

Listview on WPF takes a lot to clear thounsands of items

Steps to Reproduce

  1. Create a listview and fill with thousands of items
  2. Change the itemsource to a list of the same type but empty
  3. It will take a lot of time

Expected Behavior

The listview should clear instantly

Actual Behavior

The listview takes a lot of time to clear

Basic Information

Reproduction Link

Test - Copy.zip

yurkinh commented 4 years ago

I'm not sure that this is 100% correct solution but If in ListViewRender replace lines [286-290] foreach (var item in TemplatedItemsView.TemplatedItems) { items.Add(item); } _listview.ItemsSource = items; with line _listview.ItemsSource = TemplatedItemsView.TemplatedItems; it will start working blazingly fast. This is is only for ungrouped data. I have attached working solution with modified ListViewRendere TestList.zip

yurkinh commented 4 years ago

In original sample, the problem is with unhooking events (UnhookAndClear() method is called 20000 times for each of item). In UWP we don't have such issue : UnhookAndClear() method has not been called at all. scr

jfversluis commented 1 year ago

Taking into consideration the remaining lifetime of Xamarin.Forms, the platform this is about, the age of this issue and the traction this issue has seen I think it's unlikely that this will get fixed. If it is something that you still would like to have, please consider opening a PR. Thanks!