This question is locked. New answers and comments are not allowed.
As mentioned here, i faced some problems with this event.
So, i decided to try workaround.
As i don't have SelectedIndex during page loading, i decided to use it for blocking requests. Bu default, it should be String.Empty, but once it is set, requests can to proceed.
Event itself:
Page constructor
However, now, sometimes, ItemsLoading is not rising at all, when user scrolls down fast enough.. any suggestions? Maybe locker is not enough?
So, i decided to try workaround.
As i don't have SelectedIndex during page loading, i decided to use it for blocking requests. Bu default, it should be String.Empty, but once it is set, requests can to proceed.
public void OnNavigatedFrom() { SelectedIndex = String.Empty; // Empty, when navigating from VirtualDataCollection.Clear(); Cleanup(); }public async void OnNavigatedTo() { var answer = await _dataService.ReadFromCacheAsync(SelectedIndex); // Now, SelectedIndex holds correct id if (answer.Status == AnswerDataServiceStatus.Ok) { lock (locker) { var currentIndex = SelectedIndex; // storing SelectedIndex = String.Empty; // emptying VirtualDataCollection.Count = answer.TotalItems; VirtualDataCollection.LoadItems(0, answer.Collection); SelectedIndex = currentIndex; // restoring } } }private async void VirtualDataCollectionOnItemsLoading(object sender, VirtualizingDataCollectionItemsLoadingEventArgs e) { if (String.IsNullOrEmpty(SelectedIndex)) return; // Leaving, if id is empty var answer = await _dataService.RequestServerAsync(SelectedIndex, e.StartIndex, e.Count); if (answer.Status == AnswerDataServiceStatus.Ok) // && answer.Collection.SequenceEqual(VirtualDataCollection.)) { DispatcherHelper.CheckBeginInvokeOnUI(() => { lock (locker) { var currentIndex = SelectedIndex; // No double rising at LoadItems or Count SelectedIndex = String.Empty; VirtualDataCollection.Count = answer.TotalItems; VirtualDataCollection.LoadItems(e.StartIndex, answer.Collection); SelectedIndex = currentIndex; } }); } }Page constructor
VirtualDataCollection = new VirtualizingDataCollection(1, Constants.PAGE_SIZE); VirtualDataCollection.ItemsLoading += VirtualDataCollectionOnItemsLoading;However, now, sometimes, ItemsLoading is not rising at all, when user scrolls down fast enough.. any suggestions? Maybe locker is not enough?