WP7 Auto Grow ListBox upon reaching the last item

后端 未结 5 1486
粉色の甜心
粉色の甜心 2020-12-14 04:51

I\'m trying to achieve an effect where more items are appended to the list when the user scrolls down to the last item. I haven\'t found a way to determine if the user has s

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 05:33

    It isn't super easy to get going since there are a lot of moving parts, but here is what you can do, assuming you want a short list that loads more from your data as you get scrolling down, similar to a lot of twitter apps, etc.

    • Write your own subclass of ObservableCollection that only offers up a few items (like 20), keeping the rest held back until requested
    • Hook up to the scroll viewer (inside the listbox or container) and its visual state changed events, you can get the NotScrolling and Scrolling changes; for an example see this code by ptorr
    • When scrolling stops, use viewer scroll extensions code to see where things are extended (at the bottom or not) or just the raw scroll viewer properties to see if it is extended to the bottom
    • If so, trigger your observable collection to release another set of items.

    Sorry I don't have a complete sample ready to blog yet. Good luck!

提交回复
热议问题