Represents a dynamic data collection that provides notifications when items are added, removed, or when the list is refreshed.
Definition
Namespace:Telerik.WinControls.Data
Assembly:Telerik.WinControls.dll
Type Parameters:
T
The type of elements in the collection.
Syntax:
public class ObservableCollection<T> : Collection<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyCollectionChanging, INotifyPropertyChanged, INotifyPropertyChangingEx
Inheritance: objectCollection<T>ObservableCollection<T>
Derived Classes:
Implements:
Inherited Members
Constructors
Initializes a new instance of the ObservableCollection<T> class.
public ObservableCollection()
Initializes a new instance of the ObservableCollection<T> class that contains elements copied from the specified enumerable.
public ObservableCollection(IEnumerable<T> list)
The enumerable from which the elements are copied.
Initializes a new instance of the ObservableCollection<T> class that contains elements copied from the specified list.
public ObservableCollection(IList<T> list)
The list from which the elements are copied.
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified list.
Fields
protected const string CountString = "Count"
protected const string ItemArrayString = "Item[]"
Properties
Methods
public virtual void AddRange(IEnumerable<T> items)
public virtual void BeginItemUpdate()
Suspends event notification.
public virtual void BeginUpdate()
protected void CallCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
protected void CallCollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
Overridden. Removes all items from the collection.
protected override void ClearItems()
Overrides:
public void EndItemUpdate()
Resumes event notification.
public void EndUpdate()
Resumes event notification.
Overridden. Inserts an item into the collection at the specified index.
Raises the CollectionChanged event with the provided arguments.
protected virtual void NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
Raises the CollectionChanging event with the provided arguments.
protected virtual void NotifyListenersCollectionChanging(NotifyCollectionChangingEventArgs e)
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index)
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Calls the NotifyListenersCollectionChanged method with the provided arguments if not in a batch update.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index)
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Calls the NotifyListenersCollectionChanging method with the provided arguments if not in a batch update.
protected virtual bool OnCollectionChanging(NotifyCollectionChangingEventArgs e)
Raises the NotifyPropertyChanged event
protected virtual void OnNotifyPropertyChanged(PropertyChangedEventArgs e)
A PropertyChangedEventArgs instance containing event data.
Raises the PropertyChanged event
protected virtual void OnNotifyPropertyChanged(string propertyName)
The name of the property
Raises the NotifyPropertyChanging event
protected virtual void OnNotifyPropertyChanging(PropertyChangingEventArgsEx e)
A PropertyChangingEventArgs instance containing event data.
Raises the PropertyChanging event
protected virtual void OnNotifyPropertyChanging(string propertyName)
The name of the property
Overridden. Removes the item at the specified index of the collection.
public virtual void RemoveRange(IEnumerable<T> items)
Overridden. Replaces the element at the specified index.
Events
Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
public event NotifyCollectionChangedEventHandler CollectionChanged
Implements:
Occurs before an item is added, removed, changed, moved, or the entire list is refreshed.
public event NotifyCollectionChangingEventHandler CollectionChanging
Implements:
Occurs when a property of an object changes. Calling the event is developer's responsibility.
[Browsable(false)]
public event PropertyChangedEventHandler PropertyChanged
Implements:
Occurs before a property of an object changes.
public event PropertyChangingEventHandlerEx PropertyChanging
Implements: