DataPager 컨트롤 - 초간단 DataGrid 페이징 처리
.NET프로그래밍/Silverlight 3.0 2009. 12. 11. 13:26 |
- 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;
}
}
}
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
Silverlight에 WCF연동 (0) | 2009.12.14 |
---|---|
Silverlight에 WebService연동 (0) | 2009.12.11 |
DataGrid - 현재 선택된 행 가져오기 (0) | 2009.12.11 |
DataGrid 컨트롤로 데이터 출력 (0) | 2009.12.11 |
컨트롤(요소) 바인딩 - 컨트롤과 컨트롤간의 바인딩 (0) | 2009.12.11 |