Paging method:
Using system; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. ink; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using system. windows. controls. primitives; using system. collections. generic; namespace microblogforwp7.classes {public class utilpager {# region Paging Usage // <summary> /// paging // </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> Public void verticalscrollbar_valuechanged (Object sender, routedeventargs e) {scrollbar = (scrollbar) sender; object valueobj = scrollbar. getvalue (scrollbar. valueproperty); object maxobj = scrollbar. getvalue (scrollbar. maximumproperty); If (valueobj! = NULL & maxobj! = NULL) {double value = (double) valueobj; double max = (double) maxobj-1.0; If (value> = max) {// read data on the next page // getpublicmicroblog () ;}} public static list <t> getvisualchildcollection <t> (Object parent) where T: uielement {list <t> visualcollection = new list <t> (); getvisualchildcollection (parent as dependencyobject, visualcollection); Return visualcollection;} public static void getvisualchildc Ollection <t> (dependencyobject parent, list <t> visualcollection) where T: uielement {int COUNT = visualtreehelper. getchildrencount (parent); For (INT I = 0; I <count; I ++) {dependencyobject child = visualtreehelper. getchild (parent, I); If (child is t) {visualcollection. add (child as T);} else if (child! = NULL) {getvisualchildcollection (child, visualcollection );}}} # endregion // <summary> // obtain the child control of the control /// </Summary> // <typeparam name = "T"> child control class </typeparam> /// <Param name = "root"> parent Control </param> /// <returns> </returns> Public static t findchildoftype <t> (dependencyobject root) where T: Class {var queue = new queue <dependencyobject> (); queue. enqueue (Root); While (queue. count> 0) {dependencyobject Current = queue. dequeue (); For (INT I = visualtreehelper. getchildrencount (current)-1; 0 <= I; I --) {var child = visualtreehelper. getchild (current, I); var typedchild = Child as t; If (typedchild! = NULL) {return typedchild;} queue. enqueue (child) ;}} return NULL ;} /// <summary >/// highly sensitive page flip /// </Summary> Public static bool hightdragsensiti#{ get {return false ;}}}}
Call:
List<ScrollBar> scrollBarList = GetVisualChildCollection<ScrollBar>(listBox1); foreach (ScrollBar scrollBar in scrollBarList) { if (scrollBar.Orientation == System.Windows.Controls.Orientation.Horizontal) { } else { scrollBar.ValueChanged += new RoutedPropertyChangedEventHandler<double>(verticalScrollBar_ValueChanged); } }