Paging Method for Windows Phone development

Source: Internet
Author: User
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);                }            }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.