Windows phone開發之分頁方法

來源:互聯網
上載者:User
分頁方法:
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  分頁調用方法        /// <summary>        /// 分頁        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        public void verticalScrollBar_ValueChanged(object sender, RoutedEventArgs e)        {            ScrollBar 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)                {                    //讀取下一頁的資料                     //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 GetVisualChildCollection<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>        ///擷取控制項的子控制項        /// </summary>        /// <typeparam name="T">子控制項類</typeparam>        /// <param name="root">父控制項</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>        /// 高敏感翻頁        /// </summary>        public static bool HightDragSensitivity        {            get            {                return false;            }        }    }}

調用:

 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);                }            }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.