MasterDetailsView如何实现增量加载?

How to implement Incremental loading in MasterDetailsView?

我想在MasterDetailsView. I know we can implement Incremental loading with ISupportIncremental​Loading中实现增量加载。但有一个问题,我没有一次拥有 ObservableCollection 中的所有项目。只有当用户到达 MasterDetailsView.ItemTemplate 的末尾时,才会添加 ObservableCollection 中的项目。

我已经创建了一个函数来加载 ObservableCollection 中的更多项目,但我只想在用户到达 MasterDetailsView.ItemTemplate 末尾时调用该函数。

那我该怎么做呢?

我们可以用Incremental Loading Collection

实现增量加载
using Microsoft.Toolkit.Uwp;

public class Person
{
    public string Name { get; set; }
}
public class PeopleSource : IIncrementalSource<Person>
{
    private readonly List<Person> people;

    public async Task<IEnumerable<InfoOverView>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken))
    {
        return AddItems();
    }

    public void AddItems()
    {
        people.Clear();
        //Code to add the additional items in the people List
        return people;
    }
}

//In Page.xaml.cs
public Page()
{
    this.InitializeComponent();
    var collection = new IncrementalLoadingCollection<PeopleSource, Person>();
    MasterDetailsViewPanel.ItemsSource = collection;
}