0

我想在MasterDetailsView. 我知道我们可以使用ISupportIncremental​Loading. 但一个问题是我没有ObservableCollection一次拥有所有项目。只有ObservableCollection当用户到达MasterDetailsView.ItemTemplate.

我已经创建了一个函数来加载更多项目,ObservableCollection但我只想在用户到达MasterDetailsView.ItemTemplate.

那么我该怎么做呢?

4

1 回答 1

0

我们可以使用增量加载集合来实现增量加载

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;
}
于 2017-05-14T06:41:55.970 回答