Show / Hide Table of Contents

Interface ICollectionView

ICollectionView is an interface that applications writing their own collections can implement to enable current record management, sorting, filtering, grouping etc in a custom way.

Inherited Members
System.Collections.IEnumerable.GetEnumerator()
System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged
Namespace: System.ComponentModel
Assembly: OpenSilver.dll
Syntax
public interface ICollectionView : IEnumerable, INotifyCollectionChanged

Properties

| Improve this Doc View Source

CanFilter

Indicates whether or not this ICollectionView can do any filtering.

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

CanGroup

Returns true if this view really supports grouping. When this returns false, the rest of the interface is ignored.

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

CanSort

Whether or not this ICollectionView does any sorting.

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

Culture

Culture contains the CultureInfo used in any operations of the ICollectionView that may differ by Culture, such as sorting.

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

CurrentItem

Return current item.

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

CurrentPosition

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

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

Filter

Filter 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
Predicate<object> Filter { get; set; }
Property Value
Type Description
System.Predicate<System.Object>
| Improve this Doc View Source

GroupDescriptions

The description of grouping, indexed by level.

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

Groups

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

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

IsCurrentAfterLast

Return true if CurrentItem is beyond the end (End-Of-File).

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

IsCurrentBeforeFirst

Return true if CurrentItem is before the beginning (Beginning-Of-File).

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

IsEmpty

Returns true if the resulting (filtered) view is emtpy.

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

SortDescriptions

Collection of Sort criteria to sort items in this view over the SourceCollection.

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

Simpler implementations do not support sorting and will return an empty and immutable / read-only SortDescription collection. Attempting to modify such a collection will cause NotSupportedException. Use CanSort property on CollectionView to test if sorting is supported before modifying the returned collection.

One or more sort criteria in form of SortDescription can be added, each specifying a property and direction to sort by.

| Improve this Doc View Source

SourceCollection

SourceCollection is the original un-filtered collection of which this ICollectionView is a view.

Declaration
IEnumerable SourceCollection { get; }
Property Value
Type Description
System.Collections.IEnumerable

Methods

| 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 Filter.

Declaration
bool Contains(object item)
Parameters
Type Name Description
System.Object item
Returns
Type Description
System.Boolean
| Improve this Doc View Source

DeferRefresh()

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

Declaration
IDisposable DeferRefresh()
Returns
Type Description
System.IDisposable
| Improve this Doc View Source

MoveCurrentTo(Object)

Move CurrentItem to the given item.

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

Move CurrentItem to this item.

Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

MoveCurrentToFirst()

Move CurrentItem to the first item.

Declaration
bool MoveCurrentToFirst()
Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

MoveCurrentToLast()

Move CurrentItem to the last item.

Declaration
bool MoveCurrentToLast()
Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

MoveCurrentToNext()

Move CurrentItem to the next item.

Declaration
bool MoveCurrentToNext()
Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

MoveCurrentToPosition(Int32)

Move CurrentItem to the item at the given index.

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

Move CurrentItem to this index

Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

MoveCurrentToPrevious()

Move CurrentItem to the previous item.

Declaration
bool MoveCurrentToPrevious()
Returns
Type Description
System.Boolean

true if CurrentItem points to an item within the view.

| Improve this Doc View Source

Refresh()

Re-create the view, using any SortDescriptions.

Declaration
void Refresh()

Events

| Improve this Doc View Source

CurrentChanged

Raise this event after changing to a new current item.

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

CurrentChanging

Raise this event before change of current item pointer. Handlers can cancel the change.

Declaration
event CurrentChangingEventHandler CurrentChanging
Event Type
Type Description
CurrentChangingEventHandler
Remarks

Classes implementing ICollectionView should use the following pattern:

Raise the CurrentChanging event before any change of currency and check the return value before proceeding and raising CurrentChanged event:

     void MoveCurrentToNext()
     {
         CurrentChangingEventArgs args = new CurrentChangingEventArgs();
         OnCurrentChanging(args);
         if (!args.Cancel)
         {
             // ... update private data structures ...
             CurrentChanged();
         }
     }

  • Improve this Doc
  • View Source