I just posted a couple of blog posts ( Part 1 , Part 2 ) that give my solution to this problem. I also posted a sample on GitHub that implements my own VirtualCollection concept (I donβt know how this compares with the Infragistics control because I did not use this).
To show how easy it is to use, here are a few snippets from the example. First, here is how you use VirtualCollection , a class that coordinates data fetching:
public class MainViewModel : ViewModel { private NetflixTitlesSource _source; public VirtualCollection<Title> Items { get; private set; } public MainViewModel() { _source = new NetflixTitlesSource(); Items = new VirtualCollection<Title>(_source, pageSize: 20, cachedPages: 5); } protected override void OnViewLoaded() { Items.Refresh(); } }
In XAML, you simply bind the Items property to the ItemsSource property of a ListBox or DataGrid
For each data source, you must implement VirtualCollectionSource. Here, the two main NetflixTitlesSource methods are as follows:
public class NetflixTitlesSource : VirtualCollectionSource<Title> { protected override Task<int> GetCount() { return GetQueryResults(0, 1, null) .ContinueWith(t => (int)t.Result.TotalCount, TaskContinuationOptions.ExecuteSynchronously); } protected override Task<IList<Title>> GetPageAsyncOverride(int start, int pageSize, IList<SortDescription> sortDescriptions) { return GetQueryResults(start, pageSize, sortDescriptions) .ContinueWith(t => (IList<Title>)((IEnumerable<Title>)t.Result).ToList(), TaskContinuationOptions.ExecuteSynchronously); } private Task<QueryOperationResponse<Title>> GetQueryResults(int start, int pageSize, IList<SortDescription> sortDescriptions) {
Samuel jack
source share