Class
NotifyCollection<T>

Represents a collection that provides notifications when items are added, removed, or when the list is refreshed.

Definition

Namespace:Telerik.Collections.Generic

Assembly:Telerik.WinControls.dll

Type Parameters:

T

The type of elements in the collection.

Syntax:

cs-api-definition
public class NotifyCollection<T> : Collection<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged

Inheritance: objectCollection<T>NotifyCollection<T>

Derived Classes: ItemNotifyCollection<T>FilterDescriptorCollectionGroupDescriptorCollectionSortDescriptorCollectionEffectCollectionObjectRelationCollecionChartDataPointCollectionGanttViewDataItemCollectionGanttViewLinkDataItemCollectionGridGroupByFieldCollectionGridViewRelationCollectionRadTreeNodeCollectionRelationBindingCollectionSparkDataPointCollection

Implements: ICollectionIEnumerableIListINotifyCollectionChangedINotifyPropertyChanged

Inherited Members Collection<T>.Add(T)Collection<T>.Clear()Collection<T>.CopyTo(T[], int)Collection<T>.Contains(T)Collection<T>.GetEnumerator()Collection<T>.IndexOf(T)Collection<T>.Insert(int, T)Collection<T>.Remove(T)Collection<T>.RemoveAt(int)Collection<T>.CountCollection<T>.ItemsCollection<T>.this[int]

Constructors

NotifyCollection()

Initializes a new instance of the NotifyCollection<T> class.

Declaration

cs-api-definition
public NotifyCollection()

NotifyCollection(IList<T>)

Initializes a new instance of the NotifyCollection<T> class with the specified list.

Declaration

cs-api-definition
public NotifyCollection(IList<T> list)

Parameters

list

IList<T>

The list to wrap as a NotifyCollection.

Fields

Empty

Declaration

cs-api-definition
public static NotifyCollection<T> Empty

Field Value

NotifyCollection<T>

Properties

Suspended

Declaration

cs-api-definition
protected bool Suspended { get; }

Property Value

bool

Version

Declaration

cs-api-definition
protected int Version { get; }

Property Value

int

Methods

AddRange(IEnumerable<T>)

Adds multiple items to the collection in a batch operation.

Declaration

cs-api-definition
public void AddRange(IEnumerable<T> items)

Parameters

items

IEnumerable<T>

The enumerable collection of items to add.

Remarks

This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.

AddRange(params T[])

Adds multiple items to the collection in a batch operation.

Declaration

cs-api-definition
public void AddRange(params T[] items)

Parameters

items

T[]

The items to add to the collection.

Remarks

This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.

BeginUpdate()

Suspends change notifications until EndUpdate is called.

Declaration

cs-api-definition
public void BeginUpdate()

Remarks

Use this method to perform multiple operations without triggering notifications for each change. Always pair with EndUpdate to resume notifications.

ClearItems()

Declaration

cs-api-definition
protected override void ClearItems()

Overrides Collection<T>.ClearItems()

CreateEventArguments(NotifyCollectionChangedAction)

Declaration

cs-api-definition
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action)

Parameters

action

NotifyCollectionChangedAction

Returns

NotifyCollectionChangedEventArgs

CreateEventArguments(NotifyCollectionChangedAction, object, int)

Declaration

cs-api-definition
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object item, int index)

Parameters

action

NotifyCollectionChangedAction

item

object

index

int

Returns

NotifyCollectionChangedEventArgs

CreateEventArguments(NotifyCollectionChangedAction, object, object, int)

Declaration

cs-api-definition
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object oldItem, object item, int index)

Parameters

action

NotifyCollectionChangedAction

oldItem

object

item

object

index

int

Returns

NotifyCollectionChangedEventArgs

DeferRefresh()

Defers the refresh.

Declaration

cs-api-definition
public virtual IDisposable DeferRefresh()

Returns

IDisposable

EndUpdate()

Resumes change notifications and fires any pending notifications.

Declaration

cs-api-definition
public void EndUpdate()

EndUpdate(bool)

Declaration

cs-api-definition
public virtual void EndUpdate(bool notify)

Parameters

notify

bool

InsertItem(int, T)

Declaration

cs-api-definition
protected override void InsertItem(int index, T item)

Parameters

index

int

item

T

Overrides Collection<T>.InsertItem(int, T)

Move(int, int)

Moves an item from one index to another.

Declaration

cs-api-definition
public void Move(int oldIndex, int newIndex)

Parameters

oldIndex

int

The current index of the item.

newIndex

int

The target index for the item.

MoveItem(int, int)

Declaration

cs-api-definition
protected virtual void MoveItem(int oldIndex, int newIndex)

Parameters

oldIndex

int

newIndex

int

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Declaration

cs-api-definition
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)

Parameters

args

NotifyCollectionChangedEventArgs

OnPropertyChanged(PropertyChangedEventArgs)

Declaration

cs-api-definition
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)

Parameters

e

PropertyChangedEventArgs

OnPropertyChanged(string)

Declaration

cs-api-definition
protected void OnPropertyChanged(string propertyName)

Parameters

propertyName

string

RemoveItem(int)

Declaration

cs-api-definition
protected override void RemoveItem(int index)

Parameters

index

int

Overrides Collection<T>.RemoveItem(int)

SetItem(int, T)

Declaration

cs-api-definition
protected override void SetItem(int index, T item)

Parameters

index

int

item

T

Overrides Collection<T>.SetItem(int, T)

Events

CollectionChanged

Occurs when the collection changes.

Declaration

cs-api-definition
public event NotifyCollectionChangedEventHandler CollectionChanged

Event Value

NotifyCollectionChangedEventHandler

Implements INotifyCollectionChanged.CollectionChanged

PropertyChanged

Declaration

cs-api-definition
public event PropertyChangedEventHandler PropertyChanged

Event Value

PropertyChangedEventHandler

Implements INotifyPropertyChanged.PropertyChanged