telerik控制項進行分頁源碼

來源:互聯網
上載者:User

1.定義好分頁控制項的資料來源即可,任何設定RadGridView的資料來源指向分頁控制項即可
RadGridView設定:  
ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
2.設定分頁控制項是Source
  this.radDataPager.Source = employees;
或者     Source="{Binding DataSouce,Mode=TwoWay}"
有左邊導航的,也只要把過濾好的資料來源直接扔給分頁控制項就好了,其他的就有分頁控制項進行處理了。 

我比較喜歡ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
這句話,感覺好神奇

<UserControl x:Class="SilverlightApplication2.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"       xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"       mc:Ignorable="d"    d:DesignHeight="300" d:DesignWidth="400">    <Grid x:Name="LayoutRoot"        Background="White">        <Grid.RowDefinitions>            <RowDefinition />            <RowDefinition Height="Auto" />        </Grid.RowDefinitions>        <telerik:RadGridView x:Name="radGridView"                            ItemsSource="{Binding PagedSource, ElementName=radDataPager}"                            AutoGenerateColumns="False">            <telerik:RadGridView.Columns>                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" />                <telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyName}" />                <telerik:GridViewDataColumn DataMemberBinding="{Binding Title}" />            </telerik:RadGridView.Columns>        </telerik:RadGridView>        <telerik:RadDataPager x:Name="radDataPager"                            Grid.Row="1"                            DisplayMode="All"                            PageSize="5"                            Margin="0,10,0,0" />    </Grid></UserControl>

 

using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Collections.ObjectModel;namespace SilverlightApplication2{    public partial class MainPage : UserControl    {        public MainPage()        {            InitializeComponent();            ObservableCollection<Employee> employees = new ObservableCollection<Employee>();            employees.Add(new Employee("Maria Anders", "Alfreds Futterkiste", "Sales Representative"));            employees.Add(new Employee("Ana Trujillo", "Ana Trujillo Emparedados y helados", "Owner"));            employees.Add(new Employee("Antonio Moreno", "Antonio Moreno Taqueria", "Owner"));            employees.Add(new Employee("Thomas Hardy", "Around the Horn", "Sales Representative"));            employees.Add(new Employee("Hanna Moos", "Blauer See Delikatessen", "Sales Representative"));            employees.Add(new Employee("Frederique Citeaux", "Blondesddsl pere et fils", "Marketing Manager"));            employees.Add(new Employee("Martin Sommer", "Bolido Comidas preparadas", "Owner"));            employees.Add(new Employee("Laurence Lebihan", "Bon app'", "Owner"));            employees.Add(new Employee("Elizabeth Lincoln", "Bottom-Dollar Markets", "Accounting manager"));            employees.Add(new Employee("Victoria Ashworth", "B's Beverages", "Sales representative"));            employees.Add(new Employee("Thomas Hardy", "Around the Horn", "Sales Representative"));            employees.Add(new Employee("Hanna Moos", "Blauer See Delikatessen", "Sales Representative"));            employees.Add(new Employee("Frederique Citeaux", "Blondesddsl pere et fils", "Marketing Manager"));            employees.Add(new Employee("Martin Sommer", "Bolido Comidas preparadas", "Owner"));            employees.Add(new Employee("Laurence Lebihan", "Bon app'", "Owner"));            employees.Add(new Employee("Elizabeth Lincoln", "Bottom-Dollar Markets", "Accounting manager"));            employees.Add(new Employee("Victoria Ashworth", "B's Beverages", "Sales representative"));            this.radDataPager.Source = employees;        }    }    public class Employee    {        public Employee(string name, string companyName, string title)        {            this.Name = name;            this.CompanyName = companyName;            this.Title = title;        }        public string Name        {            get;            set;        }        public string CompanyName        {            get;            set;        }        public string Title        {            get;            set;        }    }}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.