Class NotifyCollection<T>
Represents a collection that provides notifications when items are added, removed, or when the list is refreshed.
Inheritance
Inherited Members
Namespace: Telerik.Collections.Generic
Assembly: Telerik.WinControls.dll
Syntax
public class NotifyCollection<T> : Collection<T>, IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
T
The type of elements in the collection. |
Remarks
This collection supports batch updates through BeginUpdate/EndUpdate methods, move operations, and range operations while providing change notifications and property change notifications.
Constructors
NotifyCollection()
NotifyCollection(IList<T>)
Initializes a new instance of the NotifyCollection<T> class with the specified list.
Declaration
public NotifyCollection(IList<T> list)
Parameters
System.Collections.Generic.IList<T>
list
The list to wrap as a NotifyCollection. |
Fields
Empty
Properties
Suspended
Declaration
protected bool Suspended { get; }
Property Value
System.Boolean
|
Version
Declaration
protected int Version { get; }
Property Value
System.Int32
|
Methods
AddRange(T[])
Adds multiple items to the collection in a batch operation.
Declaration
public void AddRange(params T[] items)
Parameters
T[]
items
The items to add to the collection. |
Remarks
This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.
AddRange(IEnumerable<T>)
Adds multiple items to the collection in a batch operation.
Declaration
public void AddRange(IEnumerable<T> items)
Parameters
System.Collections.Generic.IEnumerable<T>
items
The enumerable collection of items to add. |
Remarks
This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.
BeginUpdate()
Suspends change notifications until EndUpdate is called.
Declaration
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
protected override void ClearItems()
Overrides
CreateEventArguments(NotifyCollectionChangedAction)
Declaration
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action)
Parameters
NotifyCollectionChangedAction
action
|
Returns
NotifyCollectionChangedEventArgs
|
CreateEventArguments(NotifyCollectionChangedAction, Object, Int32)
Declaration
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object item, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
item
|
System.Int32
index
|
Returns
NotifyCollectionChangedEventArgs
|
CreateEventArguments(NotifyCollectionChangedAction, Object, Object, Int32)
Declaration
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object oldItem, object item, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
oldItem
|
System.Object
item
|
System.Int32
index
|
Returns
NotifyCollectionChangedEventArgs
|
DeferRefresh()
Defers the refresh.
Declaration
public virtual IDisposable DeferRefresh()
Returns
System.IDisposable
|
EndUpdate()
Resumes change notifications and fires any pending notifications.
Declaration
public void EndUpdate()
EndUpdate(Boolean)
Declaration
public virtual void EndUpdate(bool notify)
Parameters
System.Boolean
notify
|
InsertItem(Int32, T)
Declaration
protected override void InsertItem(int index, T item)
Parameters
System.Int32
index
|
T
item
|
Overrides
Move(Int32, Int32)
Moves an item from one index to another.
Declaration
public void Move(int oldIndex, int newIndex)
Parameters
System.Int32
oldIndex
The current index of the item. |
System.Int32
newIndex
The target index for the item. |
MoveItem(Int32, Int32)
Declaration
protected virtual void MoveItem(int oldIndex, int newIndex)
Parameters
System.Int32
oldIndex
|
System.Int32
newIndex
|
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Declaration
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters
NotifyCollectionChangedEventArgs
args
|
OnPropertyChanged(PropertyChangedEventArgs)
Declaration
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
Parameters
System.ComponentModel.PropertyChangedEventArgs
e
|
OnPropertyChanged(String)
Declaration
protected void OnPropertyChanged(string propertyName)
Parameters
System.String
propertyName
|
RemoveItem(Int32)
Declaration
protected override void RemoveItem(int index)
Parameters
System.Int32
index
|
Overrides
SetItem(Int32, T)
Declaration
protected override void SetItem(int index, T item)
Parameters
System.Int32
index
|
T
item
|
Overrides
Events
CollectionChanged
Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
NotifyCollectionChangedEventHandler
|
Implements
PropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
System.ComponentModel.PropertyChangedEventHandler
|