- PagedCollectionView 클래스를 사용하여 컬렉션형태의 데이터에 맞게 페이징 처리를 해주는 컨트롤




왼쪽에 있는 '도구상자'에서 "DataGrid"컨트롤을 "MainPage.xaml"파일의 "Grid"안에 떨어뜨린다.






[MainPage.xaml]

<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="RiaDataPager.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"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Grid x:Name="LayoutRoot" Background="White">

        <my:DataGrid x:Name="ctlList" AutoGenerateColumns="True"></my:DataGrid>

        <my:DataPager x:Name="ctlPager"

            PageSize="5" Source="{Binding Path=ItemsSource, ElementName=ctlList}" />       

    </Grid>

</UserControl>

 

 






[MainPage.xaml.cs]

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.Windows.Data;

 

namespace RiaDataPager

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }

 

        void MainPage_Loaded(object sender, RoutedEventArgs e)

        {

            PagedCollectionView pcv =

                new PagedCollectionView(" ".Split(' '));

            ctlList.ItemsSource = pcv;

        }

    }

}

 

 




















 

Posted by holland14
: