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

[Bug] No Data Virtualization in CollectionView #10416

Open jefffhaynes opened 4 years ago

jefffhaynes commented 4 years ago

Description

CollectionView is being groomed as a replacement for ListView. However, due to a lack of real data virtualization it is not a viable option for many scenarios. While CollectionView does support "incremental data load", it is up to the consumer to swap new data in and is cumbersome to say the least. At a minimum, the eager loading of the entire data source is not expected behavior.

Steps to Reproduce

  1. Define a data source:

    public class Source : IReadOnlyList<string>
    {
    public IEnumerator<string> GetEnumerator()
    {
        return Enumerable.Range(0, 100).Select(i =>
        {
            Debug.WriteLine($"Enumerator: {i}");
            return i.ToString();
        }).GetEnumerator();
    }
    
    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
    
    public int Count => 100;
    
    public string this[int index]
    {
        get
        {
            Debug.WriteLine($"Indexer: {index}");
            return index.ToString();
        }
    }
    }
  2. Assign the source to a CollectionView

Expected Behavior

Only visible data items should be retrieved. ListView does this when defining an IReadOnlyList data source, although even that is a seemingly arbitrary distinction.

Actual Behavior

All items are retrieved.

Basic Information

BlueRaja commented 2 years ago

Any news on this? CollectionView is basically unusable at this point