Load more items on grid view scroll end

2020-02-05 10:49发布

问题:

I am developing a Windows Store Application in XAML/C# and I have a GridView displaying 12 items at a time (3 x 4). What I need to do is once the user scrolls to the end, more items are added to the GridView. How do I catch the event for scrolling at end?? I tried many approaches, but nothing worked...

UPDATE: It took me a LOOOONG time and lots of examples to figure what I was doing wrong. ListView worked, but GridView didn't... Finally I noticed that the GridView items must have a width height in order for incremental loading to work.

回答1:

See these examples to learn how to set ObservableCollection<T> that implements the ISupportIncrementalLoading interface.

Metro: Incrementally load GridView and ListView with ISupportIncrementalLoading

From the Windows 8 Camps: GridViews/ListViews and Large Data Sets

WinRT: How to properly implement ISupportIncrementalLoading with navigation



回答2:

I would suggest that you bind your GridView to a collection that implements the ISupportIncrementalLoading interface. If you do this, the GridView can automatically load the data when the user scrolls to the end.

For a complete example on how to do this, see Microsoft's XAML data binding sample.