简体   繁体   中英

How to find out if you are at the bottom of a list box (WP7 Silverlight)

I have a list box that I am using for a leaderboard to which I add some custom controls that display the relevant information for each position. At the moment the leaderboard only shows the top 25 scores. I would really like it to load the next 25 if the user scrolls to the bottom of the list (ie number 25). This is the same behavior that can be found in the windows phone marketplace. Is there an event that fires when the user scrolls all the way to the bottom or some kind of property that would indicate this?

Extract the child scrollviewer of the listbox using

            var elt = VisualTreeHelper.GetChild(parent, i);
            if (elt is ScrollViewer) 
                            scrollViewer = (ScrollViewer)elt;

Use the following code in manipulation_completed event handler

            if ((scrollViewer.ScrollableHeight != 0 && scrollViewer.VerticalOffset != 0
                && (scrollViewer.ScrollableHeight - scrollViewer.VerticalOffset) <= 10) || scrollViewer.ScrollableHeight == 0)
                //do work here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM