Get the first and last visible element of widows phone listbox

How i can get the first and last visible element of windows phone listbox.My requirement is to load the list items based on scrolling. More detail : I am using a longlist selector for displaying items. It contains two hierarchy of lists. One list is for displaying the header items and another is for displaying the grouped item. While initial loading i will get the title and the url’s for fetching the child items of list. So here i need to load this list items(children) based on scrolling. My list contains huge no of items because of this i adopted this method. Please any one share some ideas to implement this in my app.

Answers


Check out the Colin's solution.

Here is the relevant snippet:

VirtualizingStackPanel vsp = itemsControl.Descendants<VirtualizingStackPanel>()
                                         .First() as VirtualizingStackPanel;

// iterate over each of the items in view
int firstVisibleItem = (int)vsp.VerticalOffset;
int visibleItemCount = (int)vsp.ViewportHeight;

I have used it before and it works. Please note that both properties are regular properties and not dependency properties. In case you want to bind to them.


Need Your Help

While Loop only returns one row from 9000+ records

php mysqli datatables

I had a script for this that worked great in PHP 5.3. New host only supports 5.5 so I've done some modifying. So far, I can only get one row to be returned. I've been agonising for hours and I just...

updating JUST HTML files on Google App Engine

java html google-app-engine ftp

I have a Google App Engine Application, and as part of that Application I have my standard HTML pages, Home, ContactUs, Testimonials, Pricing ETC ETC, when users click on "login" or go to a specifi...