Balraj Singh
Balraj Singh

Reputation: 3471

Implementing Inc loading in Grid View?

I have implemented incremental loading capturing the scrollviewer inside the gridview and then binding its ViewChanged event as written in the below code. What logic should i implement that when scroll reaches end of the page then only it should call the webservice? Currently I am doing the following way:

private ScrollViewer _scroll;

this._scroll = GetVisualChild<ScrollViewer>(grdVw1);
            if (_scroll != null)
                _scroll.ViewChanged += scroll_ViewChanged;

async void scrollSnap_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            // Call the web service
            if (_scrollSnap.ScrollableWidth - _scrollSnap.HorizontalOffset < 10)
            {
                // Webservice call
            }
        }

Upvotes: 0

Views: 410

Answers (1)

chue x
chue x

Reputation: 18823

One way is to implement ISupportIncrementalLoading in your data collection object. If your collection implements this, your GridView or ListView will automatically make the data load calls when the user scrolls to the end of the page.

There is also IObserveableVector, but I have not used it.

Upvotes: 1

Related Questions