ComponentOne DataGrid for WPF and Silverlight
In This Topic
    Paging Grid Data
    In This Topic

    If you are displaying a large amount of data in the grid or have a limited amount of space in your application, you might want to add paging to your C1DataGrid control. DataGrid for WPF|variable=WPF supports paging through the use of the C1DataPager control and the PagedCollectionView class. Paging the grid can decrease load time and allow users to interact more easily with the control.

    C1DataPager Control

    The C1DataPager control is very similar to the standard Microsoft DataPager control. When you add the control to your application, it will appear similar to the following image:

    The control includes First, Previous, Next, and Last buttons by default as well as a text box listing the current page and total number of pages. You can include this control in your application, and by setting the PageSize property on the control allow the grid to be paged by any amount you choose.

    PagedCollectionView Class

    The C1DataPager control provides a convenient user interface for controlling paging with a PagedCollectionView. You use the PagedCollectionView class to provide grouping, sorting, filtering, and paging functionality for any collection that implements the IEnumerable interface. You can think of a collection view as a layer on top of a binding source collection that allows you to navigate and display the collection based on sort, filter, and group queries, all without having to manipulate the underlying source collection itself.

    Using the C1DataPager Control and PagedCollectionView Class

    So suppose you might set the C1DataGrid control's C1DataGrid.ItemsSource property with the following code:

    Visual Basic
    Copy Code
    C1DataGrid1.ItemSource = data
    

     

    C#
    Copy Code
    c1DataGrid1.ItemSource = data;
    

     

    Instead, using the PagedCollectionView class, you might set the C1DataGrid control's C1DataGrid.ItemsSource property with the following code:

    Visual Basic
    Copy Code
    C1DataGrid1.ItemSource = data
    

     

    C#
    Copy Code
    c1DataGrid1.ItemSource = new PagedCollectionView(data);
    

     

    And then you might bind the C1DataPager control to the C1DataGrid control; for example in XAML markup:

    <c1ria:C1DataPager Source="{Binding ItemsSource, ElementName=c1DataGrid1}" HorizontalAlignment="Left" Name="c1DataPager1" VerticalAlignment="Top" PageSize="5" />