Edit this page

Getting Started

To learn more about the concepts behind the RadDataPager you can read the Paging Essentials topic first.

The RadDataPager is a control that allows you to split your data into pages and display it in a user friendly way. This topic will help you to quickly get started using the control. It will focus on the following:

Adding RadDataPager

In order to use RadDataPager in your project, you need to add references to the following assemblies:

  • Telerik.Windows.Controls.dll

  • Telerik.Windows.Controls.Data.dll

  • Telerik.Windows.Data.dll

After adding references to the aforementioned dlls, you can declare a new RadDataPager as any normal Silverlight/WPF control.

To use the RadDataPager in the XAML you have to add the following namespace declaration: xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

Example 1: Declare a RadDataPager

<telerik:RadDataPager x:Name="radDataPager" />

Configuring the RadDataPager

RadDataPager allows to be configured via the properties it exposes. You can do the following:

  • Manage the size of the pages via the PageSize property. Read more

  • Show and hide visual elements of a pager via the DisplayMode property. Read more

  • Implement infinite paging. Read more

Paging RadGridView

RadGridView can be paged through its RadGridView.Items collection which implements the IPagedCollectionView interface.

The collection in this example holds business objects of type Employee. You should pass it to the ItemsSource property of RadGridView.

After that, you create your RadDataPager and bind its RadDataPager.Source property to the RadGridView.Items collection using ElementName Binding.

Example 2: Paging RadGridView

<Grid x:Name="LayoutRoot"
        Background="White">    
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <telerik:RadGridView x:Name="radGridView"
                         ItemsSource="{Binding Employees}"
                         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"
                          Source="{Binding Items, ElementName=radGridView}"
                          PageSize="5" />
</Grid>

Figure 1: Paged RadGridView

Paging a Collection

To learn more about the use of the Source and the PagedSource properties, please read this topic.

RadDataPager internally uses a QueryableCollectionView for its paging mechanism, which relies on the Skip method. This requires the OrderBy method to be called over the source collection, so that it is sorted.

RadDataPager can page any collection that implements the IEnumerable interface. The only thing that you have to do is to pass the collection to its Source property.

The collection in this example will hold business objects of type Club. You can prepare a simple collection of clubs and pass it to the Source property of the RadDataPager.

Create your RadDataPager and make some basic configurations to it.

Example 3: RadDataPager bound to a collection

<telerik:RadDataPager x:Name="radDataPager"
                      PageSize="5" 
                      Source="{Binding Clubs}"/>

After the collection is passed to the Source property, it will get split into pages. In order to learn how to access the paged collection, please read the next section.

Exposing the Paged Collection

Instead of using the PagedSource property you can also wrap your collection in an IPagedCollectionView before passing it to the Source property. To learn more read this topic.

The paged collection inside the RadDataPager can be accessed via the PagedSource property. It exposes the set of data belonging to the current page. Here is an example of a ListBox that displays the data paged by the RadDataPager.

Example 4: ListBox exposing the paged collection

<Grid x:Name="LayoutRoot"
        Background="White">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
      <ListBox Name="itemsControl"
               ItemsSource="{Binding PagedSource, ElementName=radDataPager}"/>
    <telerik:RadDataPager x:Name="radDataPager"
                            Grid.Row="1"
                            DisplayMode="All"
                            PageSize="5"                          
                            Margin="0,10,0,0" 
                            Source="{Binding Clubs}"/>
</Grid>

Rad Data Pager Getting Started 02

See Also

Was this article helpful? Yes No

Give article feedback

Tell us how we can improve this article

Dummy