Bad performance on UWP ListView if ItemsSource is not an ObservableCollection
#4059 aperta il 11 ott 2018
Metriche repository
- Star
- (5644 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Description
In my application, I have a ListView with an ItemsSource that implements IEnumerable, IList, ICollection and INotifyCollectionChanged (it is a custom collection). By default, my list contains only null elements, but on the first access to an element, it is loaded asynchronously (from an sqlite database) and I use INotifyCollectionChanged to notify the load once it has been done. It works fine on Android and only items displayed on the screen are loaded. It worked well on UWP with Xamarin Forms 2.5. With Xamarin Forms 3, on UWP, since my list is not an ObservableCollection, the ListViewRenderer creates its own ObservableCollection and accesses all the elements of my source list to copy them causing asynchronous loading and a big performance problem.
Steps to Reproduce
- Create a custom collection that implement IEnumerable, IList, ICollection and INotifyCollectionChanged.
- Create a collection of this type with 1000 items.
- Use it as ListView ItemsSource on a page and run the project on UWP
Expected Behavior
The ListView should only access visible items (or a little more) and it should not copy the list because it implements all necessary interfaces.
Actual Behavior
The ListView reads the entire collection.
Basic Information
- Version with issue: 3.2.0.839982
- Last known good version: 2.5
- IDE: Visual Studio 2017
- Platform Target Frameworks:
- UWP