Export (0) Print
Expand All

PagedCollectionView Class

Silverlight

Represents a view for grouping, sorting, filtering, and navigating a paged data collection.

System.Object
  System.Windows.Data.PagedCollectionView

Namespace:  System.Windows.Data
Assembly:  System.Windows.Data (in System.Windows.Data.dll)

'Declaration
<DefaultMemberAttribute("Item")> _
Public NotInheritable Class PagedCollectionView _
	Implements ICollectionView, IEnumerable, INotifyCollectionChanged, IPagedCollectionView,  _
	IEditableCollectionView, INotifyPropertyChanged

The PagedCollectionView type exposes the following members.

  NameDescription
Public methodPagedCollectionView(IEnumerable)Initializes a new instance of the PagedCollectionView class.
Public methodPagedCollectionView(IEnumerable, Boolean, Boolean)Initializes a new instance of the PagedCollectionView class and specifies whether the data is sorted and in group order.
Top

  NameDescription
Public propertyCanAddNewGets a value that indicates whether a new item can be added to the collection.
Public propertyCanCancelEditGets a value that indicates whether the collection view can discard pending changes and restore the original values of an edited object.
Public propertyCanChangePageGets a value that indicates whether the PageIndex value can change.
Public propertyCanFilterGets a value that indicates whether this view supports filtering by way of the Filter property.
Public propertyCanGroupGets a value that indicates whether this view supports grouping.
Public propertyCanRemoveGets a value that indicates whether an item can be removed from the collection.
Public propertyCanSortGets a value that indicates whether this view supports sorting.
Public propertyCountGets the number of records in the view after filtering, sorting, and paging.
Public propertyCultureGets or sets the cultural information for any operations of the view that might differ by culture, such as sorting.
Public propertyCurrentAddItemGets the item that is being added when an AddNew transaction is in progress.
Public propertyCurrentEditItemGets the item in the collection that is being edited when an EditItem transaction is in progress.
Public propertyCurrentItemGets the current item in the view.
Public propertyCurrentPositionGets the ordinal position of the CurrentItem in the view, which might be sorted and filtered.
Public propertyFilterGets or sets a callback that is used to determine whether an item is suited for inclusion in the view.
Public propertyGroupDescriptionsGets a collection of GroupDescription objects that describe how the items in the collection are grouped in the view.
Public propertyGroupsGets the top-level groups, constructed according to the descriptions specified in the GroupDescriptions property.
Public propertyIsAddingNewGets a value that indicates whether an AddNew transaction is in progress.
Public propertyIsCurrentAfterLastGets a value that indicates whether the CurrentItem of the view is beyond the end of the collection.
Public propertyIsCurrentBeforeFirstGets a value that indicates whether the CurrentItem of the view is before the start of the collection.
Public propertyIsEditingItemGets a value that indicates whether an EditItem transaction is in progress.
Public propertyIsEmptyGets a value that indicates whether the view is empty.
Public propertyIsPageChangingGets a value that indicates whether the page index is changing.
Public propertyItemGets the item at the specified index.
Public propertyItemCountGets the minimum number of items known to be in the source collection that satisfy the current filter.
Public propertyNeedsRefreshGets a value that indicates whether this view needs to be refreshed.
Public propertyNewItemPlaceholderPositionGets or sets a value that indicates whether to include a new item placeholder in the collection view, and where to include it.
Public propertyPageIndexGets the zero-based index of the current page.
Public propertyPageSizeGets or sets the number of items to display on a page.
Public propertySortDescriptionsGets a collection of SortDescription objects that describe how the items in the collection are sorted in the view.
Public propertySourceCollectionGets the IEnumerable collection underlying this view.
Public propertyTotalItemCountGets the total number of items in the view before paging is applied.
Top

  NameDescription
Public methodAddNewAdds a new item to the underlying collection.
Public methodCancelEditEnds the edit transaction and, if it is possible, restores the original value of the item.
Public methodCancelNewEnds the add transaction and discards the pending new item.
Public methodCommitEditEnds the edit transaction and saves the pending changes.
Public methodCommitNewEnds the add transaction and saves the pending new item.
Public methodContainsReturns a value that indicates whether the specified item belongs to this collection view.
Public methodDeferRefreshEnters a defer cycle that you can use to merge changes to the view and delay automatic refresh.
Public methodEditItemBegins an edit transaction on the specified item.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an IEnumerator object that you can use to enumerate the items in the view.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetItemAtGets the item at the specified zero-based index in this PagedCollectionView, after the source collection is filtered, sorted, and paged.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfReturns the zero-based index at which the specified item is located.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodMoveCurrentToSets the specified item to be the CurrentItem in the view.
Public methodMoveCurrentToFirstSets the first item in the view as the CurrentItem.
Public methodMoveCurrentToLastSets the last item in the view as the CurrentItem.
Public methodMoveCurrentToNextSet the item after the CurrentItem in the view as the CurrentItem.
Public methodMoveCurrentToPositionSets the item at the specified index to be the CurrentItem in the view.
Public methodMoveCurrentToPreviousSets the item before the CurrentItem in the view as the CurrentItem.
Public methodMoveToFirstPageSets the first page as the current page.
Public methodMoveToLastPageSets the last page as the current page.
Public methodMoveToNextPageMoves to the page after the current page.
Public methodMoveToPageMoves to the page at the specified index.
Public methodMoveToPreviousPageMoves to the page before the current page.
Public methodPassesFilterReturns a value that indicates whether the specified item in the underlying collection belongs to the view after filters are applied.
Public methodRefreshRe-creates the view.
Public methodRemoveRemoves the specified item from the collection.
Public methodRemoveAtRemoves the item at the specified position from the collection.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventCollectionChangedOccurs when the view has changed.
Public eventCurrentChangedOccurs after the CurrentItem has changed.
Public eventCurrentChangingOccurs when the CurrentItem is changing.
Public eventPageChangedOccurs after the PageIndex has changed.
Public eventPageChangingOccurs when the PageIndex is changing.
Public eventPropertyChangedOccurs after a property value has changed.
Top

  NameDescription
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast(Of TResult)Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType(Of TResult)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an enumerator that iterates through a collection.
Explicit interface implemetationPrivate eventINotifyCollectionChanged.CollectionChangedOccurs when the items list of the collection has changed, or the collection is reset.
Explicit interface implemetationPrivate eventINotifyPropertyChanged.PropertyChangedOccurs when a property value changes.
Top

You use a PagedCollectionView to provide grouping, sorting, filtering, and paging functionality for any collection that implements the IEnumerable interface. The DataPager control provides a convenient user interface for controlling paging with a PagedCollectionView.

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.

The following code example demonstrates how to use a PagedCollectionView with a DataPager to page through data displayed in a ListBox. The List(Of T) that stores the data is wrapped in a PagedCollectionView, which provides paging functionality. Both the DataPager and the ListBox use the PagedCollectionView as their data source.


<!-- NOTE: 
  By convention, the sdk prefix indicates a URI-based XAML namespace declaration 
  for Silverlight SDK client libraries. This namespace declaration is valid for 
  Silverlight 4 only. In Silverlight 3, you must use individual XAML namespace 
  declarations for each CLR assembly and namespace combination outside the scope 
  of the default Silverlight XAML namespace. For more information, see the help 
  topic "Prefixes and Mappings for Silverlight Libraries". 
-->
<UserControl x:Class="DataPagerSample.MainPage"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
    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:DesignWidth="640" d:DesignHeight="480">
    <Grid x:Name="LayoutRoot" Width="400">
        <StackPanel Margin="10">
            <sdk:DataPager x:Name="dataPager1"
                            PageSize="5"
                            AutoEllipsis="True"
                            NumericButtonCount="3"
                            DisplayMode="FirstLastPreviousNextNumeric"
                            IsTotalItemCountFixed="True"/>

            <ListBox x:Name="listBox1" />
        </StackPanel>
    </Grid>
</UserControl>



Imports System.Windows.Data

Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
        Dim itemList As New List(Of String)
        ' Generate some items to add to the list.
        For index As Integer = 1 To 33
            Dim sb As New System.Text.StringBuilder("Item ")
            sb.Append(index.ToString)
            itemList.Add(sb.ToString)
        Next
        ' Wrap the itemList in a PagedCollectionView for paging functionality
        Dim itemListView As New PagedCollectionView(itemList)

        ' Set the DataPager and ListBox to the same data source.
        dataPager1.Source = itemListView
        listBox1.ItemsSource = itemListView
    End Sub

End Class


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft