telerik控件进行分页源码

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;
        }
    }
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

18妹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值