c# - Load more items into LonListSelector when scrolled to bottom in windows phone 8 -
i new in windows phone development , try load more items lonlistselector when scrolled bottom in windows phone 8.
i use code scrollviewer throw null value exception.
scrollviewer scrollviewer; private void mylist_loaded(object sender, routedeventargs e) { //get scrollviewer listbox scrollviewer = getscrollviewer(this.mylonglistselector); //attach custom binding check if scrollviewer verticaloffset property has changed var binding = new binding("verticaloffset") { source = scrollviewer }; var offsetchangelistener = dependencyproperty.registerattached( "listeneroffset", typeof(object), typeof(usercontrol), new propertymetadata(onscrollchanged)); scrollviewer.setbinding(offsetchangelistener, binding); } // method pull out scrollviewer public static scrollviewer getscrollviewer(dependencyobject depobj) { if (depobj scrollviewer) return depobj scrollviewer; (int = 0; < visualtreehelper.getchildrencount(depobj); i++) { var child = visualtreehelper.getchild(depobj, i); var result = getscrollviewer(child); if (result != null) return result; } return null; } public void onscrollchanged(dependencyobject sender, dependencypropertychangedeventargs e) { //we have check if values 0.0 because both set when scrollviewer loads if ((scrollviewer.scrollableheight <= scrollviewer.verticaloffset) && (scrollviewer.scrollableheight != 0.0 && scrollviewer.verticaloffset != 0.0)) { //the scrollbar @ bottom, load more results. } }
please me.
Comments
Post a Comment