New to Telerik UI for WinForms? Start a free 30-day trial

Provides a read-only indexed projection of a source sequence using a RadCollectionView<TDataItem>'s filtering, sorting, and grouping settings.

Call Load(IEnumerable<TDataItem>) to replace the indexed source sequence. The current-item members required by ICollectionView<T> are not supported: navigation returns false, the current position is -1, and explicit refresh is a no-op.

The collection-change and current-item events are raised only when the corresponding protected notification methods are invoked.

Definition

Namespace:Telerik.WinControls.Data

Assembly:Telerik.WinControls.dll

Type Parameters:

TDataItem

The data-item type shown by the snapshot.

Syntax:

C#
public class SnapshotCollectionView<TDataItem> : ISnapshotCollectionView<TDataItem>, ICollectionView<TDataItem>, IReadOnlyCollection<TDataItem>, IEnumerable where TDataItem : IDataItem

Inheritance: objectSnapshotCollectionView<TDataItem>

Implements: ICollectionView<TDataItem>IEnumerableIReadOnlyCollection<TDataItem>ISnapshotCollectionView<TDataItem>

Constructors

Creates an indexed snapshot that uses the source view's sort and group descriptors.

C#
public SnapshotCollectionView(IEnumerable<TDataItem> sourceCollection, RadCollectionView<TDataItem> sourceView)
Parameters:sourceCollectionIEnumerable<TDataItem>

The sequence to expose through the snapshot.

sourceViewRadCollectionView<TDataItem>

The view that supplies filtering, sorting, and grouping behavior.

Properties

Gets the number of items in the indexed view.

C#
public int Count { get; }

Implements: IReadOnlyCollection<TDataItem>.Count

Gets the lazily created group builder used to produce this snapshot's group hierarchy.

C#
protected virtual GroupBuilder<TDataItem> GroupBuilder { get; }

GroupComparer

IComparer<Group<TDataItem>>

Gets or sets the comparer used to order groups in this snapshot.

C#
public virtual IComparer<Group<TDataItem>> GroupComparer { get; set; }

Implements: ICollectionView<TDataItem>.GroupComparer

Gets or sets the group predicate.

C#
public virtual GroupPredicate<TDataItem> GroupPredicate { get; set; }
Property Value:

The group predicate.

Gets the groups.

C#
public GroupCollection<TDataItem> Groups { get; }
Property Value:

The groups.

Implements: ICollectionView<TDataItem>.Groups

Indexer

Index<TDataItem>

Gets the lazily created index that applies the source view's item operations.

C#
protected virtual Index<TDataItem> Indexer { get; }

SourceCollection

IEnumerable<TDataItem>

Gets the source collection.

C#
public IEnumerable<TDataItem> SourceCollection { get; }
Property Value:

The source collection.

Implements: ICollectionView<TDataItem>.SourceCollection

Gets the source view that supplies this snapshot's descriptors and filter.

C#
protected virtual RadCollectionView<TDataItem> SourceView { get; }

this[int]

TDataItem

Gets the item at a zero-based position in the indexed view.

C#
public TDataItem this[int index] { get; }
Parameters:indexint

The position of the item to retrieve.

Implements: IReadOnlyCollection<TDataItem>.this[int]

Methods

Determines whether the indexed view contains the specified item.

C#
public bool Contains(TDataItem value)
Parameters:valueTDataItem

The item to locate.

Returns:

bool

true if the item is present; otherwise, false.

Implements: IReadOnlyCollection<TDataItem>.Contains(TDataItem)

Copies the indexed items into an array starting at the specified destination index.

C#
public void CopyTo(TDataItem[] array, int index)
Parameters:arrayTDataItem[]

The destination array.

indexint

The zero-based destination index.

Implements: IReadOnlyCollection<TDataItem>.CopyTo(TDataItem[], int)

Evaluates an expression against a contiguous range of items in this snapshot.

C#
public object Evaluate(string expression, int startIndex, int count)
Parameters:expressionstring

The expression understood by the source view's expression evaluator.

startIndexint

The zero-based index of the first item to include.

countint

The number of consecutive items to include.

Returns:

object

The expression result; aggregate expressions use the range, while non-aggregate expressions use its first item. A zero-count range returns null when startIndex is a valid item index.

Exceptions: ArgumentOutOfRangeException

startIndex is outside the snapshot's item indexes.

Evaluates an expression against the specified item as it appears in this snapshot.

C#
public object Evaluate(string expression, TDataItem item)
Parameters:expressionstring

The expression understood by the source view's expression evaluator.

itemTDataItem

The item to evaluate.

Returns:

object

The evaluated result, or null if the item is not in the snapshot.

Enumerates the items in their indexed view order.

C#
public IEnumerator<TDataItem> GetEnumerator()
Returns:

IEnumerator<TDataItem>

Finds the position of an item equal to the specified value in the indexed view.

C#
public int IndexOf(TDataItem value)
Parameters:valueTDataItem

The item to locate.

Returns:

int

The zero-based position, or -1 if no equal item is present.

Implements: IReadOnlyCollection<TDataItem>.IndexOf(TDataItem)

Replaces the sequence exposed by the snapshot and reloads its index.

C#
public void Load(IEnumerable<TDataItem> source)
Parameters:sourceIEnumerable<TDataItem>

The new sequence to index.

Raises CollectionChanged for a derived implementation.

C#
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs

The collection change to publish.

Raises CurrentChanged for a derived implementation.

C#
protected virtual void OnCurrentChanged(EventArgs args)
Parameters:argsEventArgs

The current-item change data.

Raises CurrentChanging for a derived implementation.

C#
protected virtual void OnCurrentChanging(CancelEventArgs args)
Parameters:argsCancelEventArgs

The current-item change data.

Sets the view in dirty state.

C#
public void SetDirty()

Events

Occurs when this snapshot publishes a collection-change notification.

C#
public event NotifyCollectionChangedEventHandler CollectionChanged

Implements: ICollectionView<TDataItem>.CollectionChanged

Occurs when a derived implementation reports a current-item change.

C#
public event EventHandler CurrentChanged

Implements: ICollectionView<TDataItem>.CurrentChanged

Occurs when a derived implementation reports a pending current-item change.

C#
public event CancelEventHandler CurrentChanging

Implements: ICollectionView<TDataItem>.CurrentChanging