WPF ListBox Paging

Source: Internet
Author: User

        List<listboxitem> llb;//a ListBox data collection that conforms to a condition like public static list<modeldatabase> DataList = new LIST&L T      Modeldatabase> ();//total data source int pageIndex = 1;//current page int pageSize = 16;//one page maximum capacity int totalpage = 0;//Total Pages public void Takepage () {Tbindex.            Text = Pageindex.tostring (); Listbox.itemssource = LLB. Skip ((pageIndex-1) * pageSize). Take (pageSize).        ToList ();            }//Home private void Btnfirst_click (object sender, RoutedEventArgs e) {pageIndex = 1;        Takepage ();             }//Last private void Btnlast_click (object sender, RoutedEventArgs e) {pageIndex = Totalpage;        Takepage ();             }//prev private void Btnprev_click (object sender, RoutedEventArgs e) {if (PageIndex > 1) {PageIndex-= 1;            Takepage (); }}//Next private void Btnnext_click (object sender, RoutedEventArgs e)       {if (PageIndex < totalpage) {pageIndex + = 1;            Takepage ();            }}public list<listboxitem> bounddata (int _pageindex, int _pagesize, string strstring,string sign) {            LLB = new list<listboxitem> ();            List<modeldatabase> Listmodel = null; if (sign. Equals ("1")) {Listmodel = DataList.            FindAll (item = (int) Item._parentid = = Convert.toint64 (strstring)); } else if (sign. Equals ("0")) {Listmodel = DataList. Where (s = = S._modelname.contains (strstring)).            ToList (); } else {Listmodel = DataList. Where (s = = S._modelname = = strstring).            ToList ();                } foreach (Modeldatabase item in Listmodel) {ListBoxItem LBI = new ListBoxItem (); LBi. Horizontalcontentalignment = System.Windows.HorizontalAlignment.center;                StackPanel sp = new StackPanel ();                Image img = new image ();                string url = item._modelurl; Img.                Source = new BitmapImage (new Uri (@url, urikind.relative));                System.Windows.Controls.Label lable = new System.Windows.Controls.Label (); Lable.                Content = Item._modelname; Sp.                Children.add (IMG); Sp.                Children.add (lable); Sp.                Tag = Item._midelremark; LBi.                Content = SP; LBi.                MouseDoubleClick + = Lbi_mousedoubleclick; Llb.            ADD (LBI);            }//Initialize pagination element pageIndex = 1; Tbindex.            Text = Pageindex.tostring (); int count = Listmodel.            count;//total number of data bars if (count% PageSize = = 0) {totalpage = count/pagesize;            } else {totalpage = count/pagesize + 1; } tbmax. Text = totalpage.toString ();            Disableclick (TRUE); Return LLB. Skip (0). Take (pageSize).        ToList (); }

WPF ListBox Paging

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.