在显式增量加载中使用 RadDataGrid 时,如何让它执行第一次数据加载?

When using RadDataGrid in explicit incremental loading, how do I get it to do that first data load?

我在 UWP 应用程序中使用 RadDataGrid,配置为使用使用增量加载的数据源。

如果我将数据网格配置为自动增量加载,网格将加载第一个数据块。但是,如果我将其设置为显式加载,用户必须单击 "load more rows" 才能获取第一块数据,这对用户来说不是很好,特别是因为 "more" 意味着已经有一些数据!

有没有办法触发 RadDataGrid 自动加载第一个数据块,即使它设置为显式?

您似乎在使用 IncrementalLoadingCollection,这是需要手动增量加载的默认实现。如果你不想用户点击"load more rows"第一个块,你可以简单地通过LoadMoreItemsAsync方法加载第一个块数据代码。例如,

<telerikGrid:RadDataGrid
    x:Name="grid"
    IncrementalLoadingMode="Explicit"
    ItemsSource="{Binding}" />

后面的代码:

private void Page_Loaded(object sender, RoutedEventArgs e)
{
   IncrementalLoadingCollection<Data> collection = new IncrementalLoadingCollection<Data>(
   async count =>
   {
       return (from c in Enumerable.Range(0, 10)
               select new Data { Category = "Name " + c }).ToList();
   })
    { BatchSize = 100 };

    this.DataContext = collection;
    collection.LoadMoreItemsAsync(10);
}

更多详情请参考this article