Class PagedCollectionView
PagedCollectionView view over an IEnumerable.
Inheritance
Implements
Inherited Members
Namespace: System.Windows.Data
Assembly: OpenSilver.dll
Syntax
public sealed class PagedCollectionView : ICollectionView, IEnumerable, INotifyCollectionChanged, IPagedCollectionView, IEditableCollectionView, INotifyPropertyChanged
Constructors
| Improve this Doc View SourcePagedCollectionView(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 |
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 SourceCanAddNew
Gets a value indicating whether the view supports AddNew.
Declaration
public bool CanAddNew { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
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 |
CanFilter
Gets a value indicating whether we support filtering with this ICollectionView.
Declaration
public bool CanFilter { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
CanRemove
Gets a value indicating whether the view supports Remove and RemoveAt.
Declaration
public bool CanRemove { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanSort
Gets a value indicating whether we support sorting with this ICollectionView.
Declaration
public bool CanSort { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
Culture
Gets or sets Culture to use during sorting.
Declaration
public CultureInfo Culture { get; set; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo |
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 |
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 |
CurrentItem
Gets the "current item" for this view
Declaration
public object CurrentItem { get; }
Property Value
Type | Description |
---|---|
System.Object |
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 |
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. |
GroupDescriptions
Gets the description of grouping, indexed by level.
Declaration
public ObservableCollection<GroupDescription> GroupDescriptions { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<GroupDescription> |
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> |
IsAddingNew
Gets a value indicating whether an "AddNew" transaction is in progress.
Declaration
public bool IsAddingNew { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
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 |
IsEditingItem
Gets a value indicating whether an EditItem transaction is in progress.
Declaration
public bool IsEditingItem { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsEmpty
Gets a value indicating whether the resulting (filtered) view is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
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 |
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 |
NeedsRefresh
Gets a value indicating whether this view needs to be refreshed.
Declaration
public bool NeedsRefresh { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
PageIndex
Gets the current page we are on. (zero based)
Declaration
public int PageIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
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 |
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. |
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 |
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 SourceAddNew()
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 |
CancelEdit()
Complete the transaction started by EditItem(Object). The pending changes (if any) to the item are discarded.
Declaration
public void CancelEdit()
CancelNew()
Complete the transaction started by AddNew. The new item is removed from the collection.
Declaration
public void CancelNew()
CommitEdit()
Complete the transaction started by EditItem(Object). The pending changes (if any) to the item are committed.
Declaration
public void CommitEdit()
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()
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 |
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 |
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 |
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 |
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 |
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 |
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 |
MoveCurrentToFirst()
Move to the first item.
Declaration
public bool MoveCurrentToFirst()
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful |
MoveCurrentToLast()
Move to the last item.
Declaration
public bool MoveCurrentToLast()
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful |
MoveCurrentToNext()
Move to the next item.
Declaration
public bool MoveCurrentToNext()
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful |
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 |
MoveCurrentToPrevious()
Move to the previous item.
Declaration
public bool MoveCurrentToPrevious()
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful |
MoveToFirstPage()
Moves to the first page.
Declaration
public bool MoveToFirstPage()
Returns
Type | Description |
---|---|
System.Boolean | Whether or not the move was successful. |
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. |
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. |
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. |
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. |
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 |
Refresh()
Re-create the view, using any SortDescriptions and/or Filters.
Declaration
public void Refresh()
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 |
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 SourceCollectionChanged
Raise this event when the (filtered) view changes
Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Type | Description |
---|---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |
CurrentChanged
Raised when the CurrentItem property changed
Declaration
public event EventHandler CurrentChanged
Event Type
Type | Description |
---|---|
System.EventHandler |
CurrentChanging
Raised when the CurrentItem property is changing
Declaration
public event CurrentChangingEventHandler CurrentChanging
Event Type
Type | Description |
---|---|
CurrentChangingEventHandler |
PageChanged
Raised when a page index change completed
Declaration
public event EventHandler<EventArgs> PageChanged
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |
PageChanging
Raised when a page index change is requested
Declaration
public event EventHandler<PageChangingEventArgs> PageChanging
Event Type
Type | Description |
---|---|
System.EventHandler<PageChangingEventArgs> |
PropertyChanged
PropertyChanged event.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Interface Implementation for GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | IEnumerator that we get from our internal collection |
INotifyCollectionChanged.CollectionChanged
CollectionChanged event (per INotifyCollectionChanged).
Declaration
event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged
Returns
Type | Description |
---|---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |
INotifyPropertyChanged.PropertyChanged
PropertyChanged event (per INotifyPropertyChanged)
Declaration
event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
Returns
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |