アプリ ページ (アイテム ページ テンプレート)に listview (スナップ状態の場合) と gridview (通常の状態の場合) があり、どちらもインターフェイスを実装するコレクションにバインドされていISupportIncrementalLoading
ます。実装されたメソッドは次のとおりです。
public HasMoreItemsDelegate MoreItemsExist { get; set; }
public LoadMoreItemsDelegate<T> ItemsLoadAsync { get; set; }
public bool HasMoreItems
{
get
{
return this.MoreItemsExist();
}
}
private bool isLoading;
public bool IsLoading
{
get
{
return this.isLoading;
}
private set
{
this.isLoading = value;
this.OnPropertyChanged("IsLoading");
}
}
public Windows.Foundation.IAsyncOperation<LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
{
if (this.IsLoading)
{
throw new InvalidOperationException("Only one operation in flight at a time");
}
this.IsLoading = true;
return AsyncInfo.Run((c) => LoadMoreItemsAsync(c, count));
}
async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c, uint count)
{
try
{
IEnumerable<T> itemsToAdd = await ItemsLoadAsync(c, count);
foreach (var item in itemsToAdd)
{
this.Add(item);
}
return new LoadMoreItemsResult { Count = (uint)itemsToAdd.Count() };
}
finally
{
this.IsLoading = false;
}
}
私が遭遇する問題は次のとおりです。アプリがスナップ モードで、リストビューとグリッドビューを含むページに移動すると、両方のビューが呼び出さLoadMoreItemsAsync
れ、例外句を入力しますが、通常 (フルスクリーン) モードでは、グリッドビューのみが呼び出されます。メソッドであり、リストビューはそうではありません。