How to scrolling up and down using Incremental Loading Collection in a list view using UWP?

  c++, listview, uwp, visual-studio, windows

This example of IncrementalLoadingCollection shows how to created an app with Incremental Loading Collection (Infinite scrolling) when scrolling down.

XAML:

<ListView x:Name="PeopleListView">
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="local:Person">
            <TextBlock Text="{x:Bind Name}" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

C#:

public class Person
{
    public string Name { get; set; }
}

public class PeopleSource : IIncrementalSource<Person>
{
    private readonly List<Person> people;

    public PeopleSource()
    {
        // Populate people
        ...
    }
    public async Task<IEnumerable<Person>> GetPagedItemsAsync(int pageIndex, int pageSize)
    {
        // Gets items from the collection according to pageIndex and pageSize parameters.
        var result = (from p in people
                    select p).Skip(pageIndex * pageSize).Take(pageSize);
    }
}    

var collection = new IncrementalLoadingCollection<PeopleSource, Person>();
PeopleListView.ItemsSource = collection;

enter image description here

But I need the view to starts showing from middle of the list, and if scrolling up and down, the items should be incrementally loaded like already happens when
scrolling down. Does anyone know how to do this using IncrementalLoadingCollection or can suggest a solution? Grateful.

Source: Windows Questions

LEAVE A COMMENT