Show / Hide Table of Contents

Class PagedCollectionView

PagedCollectionView view over an IEnumerable.

Inheritance
System.Object
PagedCollectionView
Implements
ICollectionView
System.Collections.IEnumerable
System.Collections.Specialized.INotifyCollectionChanged
IPagedCollectionView
IEditableCollectionView
System.ComponentModel.INotifyPropertyChanged
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Data
Assembly: OpenSilver.Data.dll
Syntax
public sealed class PagedCollectionView : ICollectionView, IEnumerable, INotifyCollectionChanged, IPagedCollectionView, IEditableCollectionView, INotifyPropertyChanged

Constructors

| Improve this Doc View Source

PagedCollectionView(IEnumerable)

Helper constructor that sets default values for isDataSorted and isDataInGroupOrder.

Declaration
public PagedCollectionView(IEnumerable source)
Parameters
Type Name Description
System.Collections.IEnumerable source

The source for the collection

| Improve this Doc View Source

PagedCollectionView(IEnumerable, Boolean, Boolean)

Initializes a new instance of the PagedCollectionView class.

Declaration
public PagedCollectionView(IEnumerable source, bool isDataSorted, bool isDataInGroupOrder)
Parameters
Type Name Description
System.Collections.IEnumerable source

The source for the collection

System.Boolean isDataSorted

Determines whether the source is already sorted

System.Boolean isDataInGroupOrder

Whether the source is already in the correct order for grouping

Properties

| Improve this Doc View Source

CanAddNew

Gets a value indicating whether the view supports AddNew.

Declaration
public bool CanAddNew { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanCancelEdit

Gets a value indicating whether the view supports the notion of "pending changes" on the current edit item. This may vary, depending on the view and the particular item. For example, a view might return true if the current edit item implements IEditableObject, or if the view has special knowledge about the item that it can use to support rollback of pending changes.

Declaration
public bool CanCancelEdit { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanChangePage

Gets a value indicating whether the PageIndex value is allowed to change or not.

Declaration
public bool CanChangePage { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanFilter

Gets a value indicating whether we support filtering with this ICollectionView.

Declaration
public bool CanFilter { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanGroup

Gets a value indicating whether this view supports grouping. When this returns false, the rest of the interface is ignored.

Declaration
public bool CanGroup { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanRemove

Gets a value indicating whether the view supports Remove and RemoveAt.

Declaration
public bool CanRemove { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanSort

Gets a value indicating whether we support sorting with this ICollectionView.

Declaration
public bool CanSort { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Count

Gets the number of records in the view after filtering, sorting, and paging.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Culture

Gets or sets Culture to use during sorting.

Declaration
public CultureInfo Culture { get; set; }
Property Value
Type Description
System.Globalization.CultureInfo
| Improve this Doc View Source

CurrentAddItem

Gets the new item when an AddNew transaction is in progress Otherwise it returns null.

Declaration
public object CurrentAddItem { get; }
Property Value
Type Description
System.Object
| Improve this Doc View Source

CurrentEditItem

Gets the affected item when an EditItem transaction is in progress Otherwise it returns null.

Declaration
public object CurrentEditItem { get; }
Property Value
Type Description
System.Object
| Improve this Doc View Source

CurrentItem

Gets the "current item" for this view

Declaration
public object CurrentItem { get; }
Property Value
Type Description
System.Object
| Improve this Doc View Source

CurrentPosition

Gets the ordinal position of the CurrentItem within the (optionally sorted and filtered) view.

Declaration
public int CurrentPosition { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Filter

Gets or sets the Filter, which is a callback set by the consumer of the ICollectionView and used by the implementation of the ICollectionView to determine if an item is suitable for inclusion in the view.

Declaration
public Predicate<object> Filter { get; set; }
Property Value
Type Description
System.Predicate<System.Object>
Exceptions
Type Condition
System.NotSupportedException

Simpler implementations do not support filtering and will throw a NotSupportedException. Use CanFilter property to test if filtering is supported before assigning a non-null value.

| Improve this Doc View Source

GroupDescriptions

Gets the description of grouping, indexed by level.

Declaration
public ObservableCollection<GroupDescription> GroupDescriptions { get; }
Property Value
Type Description
System.Collections.ObjectModel.ObservableCollection<GroupDescription>
| Improve this Doc View Source

Groups

Gets the top-level groups, constructed according to the descriptions given in GroupDescriptions.

Declaration
public ReadOnlyObservableCollection<object> Groups { get; }
Property Value
Type Description
System.Collections.ObjectModel.ReadOnlyObservableCollection<System.Object>
| Improve this Doc View Source

IsAddingNew

Gets a value indicating whether an "AddNew" transaction is in progress.

Declaration
public bool IsAddingNew { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsCurrentAfterLast

Gets a value indicating whether currency is beyond the end (End-Of-File).

Declaration
public bool IsCurrentAfterLast { get; }
Property Value
Type Description
System.Boolean

Whether IsCurrentAfterLast

| Improve this Doc View Source

IsCurrentBeforeFirst

Gets a value indicating whether currency is before the beginning (Beginning-Of-File).

Declaration
public bool IsCurrentBeforeFirst { get; }
Property Value
Type Description
System.Boolean

Whether IsCurrentBeforeFirst

| Improve this Doc View Source

IsEditingItem

Gets a value indicating whether an EditItem transaction is in progress.

Declaration
public bool IsEditingItem { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsEmpty

Gets a value indicating whether the resulting (filtered) view is empty.

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsPageChanging

Gets a value indicating whether a page index change is in process or not.

Declaration
public bool IsPageChanging { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Item[Int32]

Return the item at the specified index

Declaration
public object this[int index] { get; }
Parameters
Type Name Description
System.Int32 index

Index of the item we want to retrieve

Property Value
Type Description
System.Object

The item at the specified index

| Improve this Doc View Source

ItemCount

Gets the minimum number of items known to be in the source collection that verify the current filter if any

Declaration
public int ItemCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NeedsRefresh

Gets a value indicating whether this view needs to be refreshed.

Declaration
public bool NeedsRefresh { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

NewItemPlaceholderPosition

Gets or sets whether to include a placeholder for a new item, and if so, where to put it. Only the value NewItemPlaceholderPosition.None is supported.

Declaration
public NewItemPlaceholderPosition NewItemPlaceholderPosition { get; set; }
Property Value
Type Description
NewItemPlaceholderPosition
| Improve this Doc View Source

PageIndex

Gets the current page we are on. (zero based)

Declaration
public int PageIndex { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

PageSize

Gets or sets the number of items to display on a page. If the PageSize = 0, then we are not paging, and will display all items in the collection. Otherwise, we will have separate pages for the items to display.

Declaration
public int PageSize { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

SortDescriptions

Gets the Sort criteria to sort items in collection.

Declaration
public SortDescriptionCollection SortDescriptions { get; }
Property Value
Type Description
SortDescriptionCollection
Remarks

Clear a sort criteria by assigning SortDescription.Empty to this property. One or more sort criteria in form of SortDescription can be used, each specifying a property and direction to sort by.

Exceptions
Type Condition
System.NotSupportedException

Simpler implementations do not support sorting and will throw a NotSupportedException. Use CanSort property to test if sorting is supported before adding to SortDescriptions.

| Improve this Doc View Source

SourceCollection

Gets the source of the IEnumerable collection we are using for our view.

Declaration
public IEnumerable SourceCollection { get; }
Property Value
Type Description
System.Collections.IEnumerable
| Improve this Doc View Source

TotalItemCount

Gets the total number of items in the view before paging is applied.

Declaration
public int TotalItemCount { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AddNew()

Add a new item to the underlying collection. Returns the new item. After calling AddNew and changing the new item as desired, either CommitNew or CancelNew" should be called to complete the transaction.

Declaration
public object AddNew()
Returns
Type Description
System.Object

The new item we are adding

| Improve this Doc View Source

CancelEdit()

Complete the transaction started by EditItem(Object). The pending changes (if any) to the item are discarded.

Declaration
public void CancelEdit()
| Improve this Doc View Source

CancelNew()

Complete the transaction started by AddNew. The new item is removed from the collection.

Declaration
public void CancelNew()
| Improve this Doc View Source

CommitEdit()

Complete the transaction started by EditItem(Object). The pending changes (if any) to the item are committed.

Declaration
public void CommitEdit()
| Improve this Doc View Source

CommitNew()

Complete the transaction started by AddNew. We follow the WPF convention in that the view's sort, filter, and paging specifications (if any) are applied to the new item.

Declaration
public void CommitNew()
| Improve this Doc View Source

Contains(Object)

Return true if the item belongs to this view. No assumptions are made about the item. This method will behave similarly to IList.Contains(). If the caller knows that the item belongs to the underlying collection, it is more efficient to call PassesFilter.

Declaration
public bool Contains(object item)
Parameters
Type Name Description
System.Object item

The item we are checking to see whether it is within the collection

Returns
Type Description
System.Boolean

Boolean value of whether or not the collection contains the item

| Improve this Doc View Source

DeferRefresh()

Enter a Defer Cycle. Defer cycles are used to coalesce changes to the ICollectionView.

Declaration
public IDisposable DeferRefresh()
Returns
Type Description
System.IDisposable

IDisposable used to notify that we no longer need to defer, when we dispose

| Improve this Doc View Source

EditItem(Object)

Begins an editing transaction on the given item. The transaction is completed by calling either CommitEdit or CancelEdit. Any changes made to the item during the transaction are considered "pending", provided that the view supports the notion of "pending changes" for the given item.

Declaration
public void EditItem(object item)
Parameters
Type Name Description
System.Object item

Item we want to edit

| Improve this Doc View Source

GetEnumerator()

Implementation of IEnumerable.GetEnumerator(). This provides a way to enumerate the members of the collection without changing the currency.

Declaration
public IEnumerator GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

IEnumerator for the collection

| Improve this Doc View Source

GetItemAt(Int32)

Retrieve item at the given zero-based index in this PagedCollectionView, after the source collection is filtered, sorted, and paged.

Declaration
public object GetItemAt(int index)
Parameters
Type Name Description
System.Int32 index

Index of the item we want to retrieve

Returns
Type Description
System.Object

Item at specified index

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if index is out of range

| Improve this Doc View Source

IndexOf(Object)

Return the index where the given item appears, or -1 if doesn't appear.

Declaration
public int IndexOf(object item)
Parameters
Type Name Description
System.Object item

Item we are searching for

Returns
Type Description
System.Int32

Index of specified item

| Improve this Doc View Source

MoveCurrentTo(Object)

Move to the given item.

Declaration
public bool MoveCurrentTo(object item)
Parameters
Type Name Description
System.Object item

Item we want to move the currency to

Returns
Type Description
System.Boolean

Whether the operation was successful

| Improve this Doc View Source

MoveCurrentToFirst()

Move to the first item.

Declaration
public bool MoveCurrentToFirst()
Returns
Type Description
System.Boolean

Whether the operation was successful

| Improve this Doc View Source

MoveCurrentToLast()

Move to the last item.

Declaration
public bool MoveCurrentToLast()
Returns
Type Description
System.Boolean

Whether the operation was successful

| Improve this Doc View Source

MoveCurrentToNext()

Move to the next item.

Declaration
public bool MoveCurrentToNext()
Returns
Type Description
System.Boolean

Whether the operation was successful

| Improve this Doc View Source

MoveCurrentToPosition(Int32)

Move CurrentItem to this index

Declaration
public bool MoveCurrentToPosition(int position)
Parameters
Type Name Description
System.Int32 position

Position we want to move the currency to

Returns
Type Description
System.Boolean

True if the resulting CurrentItem is an item within the view; otherwise False

| Improve this Doc View Source

MoveCurrentToPrevious()

Move to the previous item.

Declaration
public bool MoveCurrentToPrevious()
Returns
Type Description
System.Boolean

Whether the operation was successful

| Improve this Doc View Source

MoveToFirstPage()

Moves to the first page.

Declaration
public bool MoveToFirstPage()
Returns
Type Description
System.Boolean

Whether or not the move was successful.

| Improve this Doc View Source

MoveToLastPage()

Moves to the last page. The move is only attempted when TotalItemCount is known.

Declaration
public bool MoveToLastPage()
Returns
Type Description
System.Boolean

Whether or not the move was successful.

| Improve this Doc View Source

MoveToNextPage()

Moves to the page after the current page we are on.

Declaration
public bool MoveToNextPage()
Returns
Type Description
System.Boolean

Whether or not the move was successful.

| Improve this Doc View Source

MoveToPage(Int32)

Requests a page move to page pageIndex.

Declaration
public bool MoveToPage(int pageIndex)
Parameters
Type Name Description
System.Int32 pageIndex

Index of the target page

Returns
Type Description
System.Boolean

Whether or not the move was successfully initiated.

| Improve this Doc View Source

MoveToPreviousPage()

Moves to the page before the current page we are on.

Declaration
public bool MoveToPreviousPage()
Returns
Type Description
System.Boolean

Whether or not the move was successful.

| Improve this Doc View Source

PassesFilter(Object)

Return true if the item belongs to this view. The item is assumed to belong to the underlying DataCollection; this method merely takes filters into account. It is commonly used during collection-changed notifications to determine if the added/removed item requires processing. Returns true if no filter is set on collection view.

Declaration
public bool PassesFilter(object item)
Parameters
Type Name Description
System.Object item

The item to compare against the Filter

Returns
Type Description
System.Boolean

Whether the item passes the filter

| Improve this Doc View Source

Refresh()

Re-create the view, using any SortDescriptions and/or Filters.

Declaration
public void Refresh()
| Improve this Doc View Source

Remove(Object)

Remove the given item from the underlying collection. It needs to be in the current filtered, sorted, and paged view to call this.

Declaration
public void Remove(object item)
Parameters
Type Name Description
System.Object item

Item we want to remove

| Improve this Doc View Source

RemoveAt(Int32)

Remove the item at the given index from the underlying collection. The index is interpreted with respect to the view (filtered, sorted, and paged list).

Declaration
public void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

Index of the item we want to remove

Events

| Improve this Doc View Source

CollectionChanged

Raise this event when the (filtered) view changes

Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Type Description
System.Collections.Specialized.NotifyCollectionChangedEventHandler
| Improve this Doc View Source

CurrentChanged

Raised when the CurrentItem property changed

Declaration
public event EventHandler CurrentChanged
Event Type
Type Description
System.EventHandler
| Improve this Doc View Source

CurrentChanging

Raised when the CurrentItem property is changing

Declaration
public event CurrentChangingEventHandler CurrentChanging
Event Type
Type Description
CurrentChangingEventHandler
| Improve this Doc View Source

PageChanged

Raised when a page index change completed

Declaration
public event EventHandler<EventArgs> PageChanged
Event Type
Type Description
System.EventHandler<System.EventArgs>
| Improve this Doc View Source

PageChanging

Raised when a page index change is requested

Declaration
public event EventHandler<PageChangingEventArgs> PageChanging
Event Type
Type Description
System.EventHandler<PageChangingEventArgs>
| Improve this Doc View Source

PropertyChanged

PropertyChanged event.

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
System.ComponentModel.PropertyChangedEventHandler

Explicit Interface Implementations

| Improve this Doc View Source

IEnumerable.GetEnumerator()

Interface Implementation for GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

IEnumerator that we get from our internal collection

| Improve this Doc View Source

INotifyCollectionChanged.CollectionChanged

CollectionChanged event (per INotifyCollectionChanged).

Declaration
event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged
Returns
Type Description
System.Collections.Specialized.NotifyCollectionChangedEventHandler
| Improve this Doc View Source

INotifyPropertyChanged.PropertyChanged

PropertyChanged event (per INotifyPropertyChanged)

Declaration
event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
Returns
Type Description
System.ComponentModel.PropertyChangedEventHandler

Implements

ICollectionView
System.Collections.IEnumerable
System.Collections.Specialized.INotifyCollectionChanged
IPagedCollectionView
IEditableCollectionView
System.ComponentModel.INotifyPropertyChanged
  • Improve this Doc
  • View Source