The GridView scrolls Horizontally and the screen can display up to 10 items.
However when the page is loaded, the GridView is going insane and requesting to load 2475 items in LoadMoreItemAsync
.
I limited the fetch function for each call to return 10 items each time. It just repeatedly calling LoadMoreItemAsync
.
Now basically when I am not even scrolling the GridView it just loads itself.
Here is the GridView I used
<GridView ItemsSource="{Binding Data}" IncrementalLoadingThreshold="0">
<GridView.ItemTemplate>
<DataTemplate>
<Image
Margin="5"
Stretch="UniformToFill"
Source="{Binding Banner}"
/>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="5" ItemWidth="192" ItemHeight="250" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
Here's the code behind
public IAsyncOperation<LoadMoreItemsResult> LoadMoreItemsAsync( uint count )
{
Logger.Log( ID, string.Format( "Requesting to load {0} items", count ) );
return Task.Run( async () =>
{
TaskCompletionSource<uint> ItemsLoaded = new TaskCompletionSource<uint>();
ConnectedLoader.Connector = ( BookItem[] b ) =>
{
IEnumerable<T> Converted = Convert( b );
uint i = 0;
foreach ( T a in Converted )
{
Add( a ); i++;
}
ItemsLoaded.SetResult( i );
};
ConnectedLoader.NextPage();
return new LoadMoreItemsResult() { Count = await ItemsLoaded.Task };
} ).AsAsyncOperation();
}
So how do I tell the GridView not to load so many items?