Skip to content

Xamarin.Forms example #12

Description

@raV720

I am trying to implement dynamic loading items to ListView in Xamarin.Forms, but I cannot get it working. ListView loads whole collection instead of first page only. The method GetItemsAt of IPagedSourceProvider is called many times, until the end of data source.
Maybe someone can provide working example for Xamarin.Forms (best would be for WinRT platform)?

my code is:

public class PagedCollectionProvider<T> : AlphaChiTech.Virtualization.IPagedSourceProvider<T>
{
    private IEnumerable<T> Collection;

    public PagedCollectionProvider(IEnumerable<T> Collection)
    {
        this.Collection = Collection;
    }

    public int Count
    {
        get
        {
            var coll = Collection as ICollection<T>;
            if (coll != null)
                return coll.Count;

            return Collection.Count();
        }
    }

    public PagedSourceItemsPacket<T> GetItemsAt(int pageoffset, int count, bool usePlaceholder)
    {
        return new PagedSourceItemsPacket<T>()
        {
            LoadedAt = DateTime.Now,
            Items = Collection.Skip(pageoffset).Take(count)
        };
    }

    public int IndexOf(T item)
    {
        var list = Collection as IList<T>;
        if (list != null)
            return list.IndexOf(item);

        return Collection.IndexOf(item);
    }

    public void OnReset(int count)
    {

    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions