Class ObservableCollection<T>
Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.Data
Assembly: Telerik.WinControls.dll
Syntax
public class ObservableCollection<T> : Collection<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyCollectionChanging, INotifyPropertyChanged, INotifyPropertyChangingEx
Type Parameters
T
|
Constructors
ObservableCollection()
Initializes a new instance of the ObservableCollection class.
Declaration
public ObservableCollection()
ObservableCollection(IEnumerable<T>)
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified list.
Declaration
public ObservableCollection(IEnumerable<T> list)
Parameters
System.
|
ObservableCollection(IList<T>)
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified list.
Declaration
public ObservableCollection(IList<T> list)
Parameters
System.
|
ObservableCollection(ObservableCollection<T>)
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified list.
Declaration
public ObservableCollection(ObservableCollection<T> list)
Parameters
Observable
|
Fields
CountString
Declaration
protected const string CountString = "Count"
Field Value
System.
|
ItemArrayString
Declaration
protected const string ItemArrayString = "Item[]"
Field Value
System.
|
Properties
IsUpdated
true to indicate the collection has completed update; otherwise false.
Declaration
public bool IsUpdated { get; }
Property Value
System.
|
Methods
AddRange(IEnumerable<T>)
Declaration
public virtual void AddRange(IEnumerable<T> items)
Parameters
System.
|
BeginItemUpdate()
Declaration
public virtual void BeginItemUpdate()
BeginUpdate()
Suspends event notification.
Declaration
public virtual void BeginUpdate()
CallCollectionChanged(Object, NotifyCollectionChangedEventArgs)
Declaration
protected void CallCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
System.
|
Notify
|
CallCollectionChanging(Object, NotifyCollectionChangingEventArgs)
Declaration
protected void CallCollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
Parameters
System.
|
Notify
|
ClearItems()
Overridden. Removes all items from the collection.
Declaration
protected override void ClearItems()
Overrides
EndItemUpdate()
Declaration
public void EndItemUpdate()
EndItemUpdate(Boolean)
Resumes event notification.
Declaration
public virtual void EndItemUpdate(bool notifyUpdates)
Parameters
System.
|
EndUpdate()
Declaration
public void EndUpdate()
EndUpdate(Boolean)
Resumes event notification.
Declaration
public virtual void EndUpdate(bool notifyUpdates)
Parameters
System.
|
InsertItem(Int32, T)
Overridden. Inserts an item into the collection at the specified index.
Declaration
protected override void InsertItem(int index, T item)
Parameters
System.
|
T
item
|
Overrides
InsertItem(Int32, T, Action<T>)
Declaration
protected virtual void InsertItem(int index, T item, Action<T> approvedAction)
Parameters
System.
|
T
item
|
System.
|
Move(Int32, Int32)
Moves the item at the specified index to a new location in the collection.
Declaration
public void Move(int oldIndex, int newIndex)
Parameters
System.
|
System.
|
MoveItem(Int32, Int32)
Moves the item at the specified index to a new location in the collection.
Declaration
protected virtual void MoveItem(int oldIndex, int newIndex)
Parameters
System.
|
System.
|
NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs)
Raises the CollectionChanged event with the provided arguments.
Declaration
protected virtual void NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
NotifyListenersCollectionChanging(NotifyCollectionChangingEventArgs)
Raises the CollectionChanging event with the provided arguments.
Declaration
protected virtual void NotifyListenersCollectionChanging(NotifyCollectionChangingEventArgs e)
Parameters
OnCollectionChanged(NotifyCollectionChangedAction, Object, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index)
Parameters
Notify
|
System.
|
System.
|
OnCollectionChanged(NotifyCollectionChangedAction, Object, Int32, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
Parameters
Notify
|
System.
|
System.
|
System.
|
OnCollectionChanged(NotifyCollectionChangedAction, Object, Object, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Parameters
Notify
|
System.
|
System.
|
System.
|
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Calls the NotifyListenersCollectionChanged method with the provided arguments if not in a batch update.
Declaration
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
OnCollectionChanging(NotifyCollectionChangedAction, Object, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index)
Parameters
Notify
|
System.
|
System.
|
Returns
System.
|
OnCollectionChanging(NotifyCollectionChangedAction, Object, Int32, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
Parameters
Notify
|
System.
|
System.
|
System.
|
Returns
System.
|
OnCollectionChanging(NotifyCollectionChangedAction, Object, Object, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Parameters
Notify
|
System.
|
System.
|
System.
|
Returns
System.
|
OnCollectionChanging(NotifyCollectionChangingEventArgs)
Calls the NotifyListenersCollectionChanging method with the provided arguments if not in a batch update.
Declaration
protected virtual bool OnCollectionChanging(NotifyCollectionChangingEventArgs e)
Parameters
Returns
System.
|
OnCollectionReset(IList)
Declaration
protected void OnCollectionReset(IList oldItems)
Parameters
System.
|
OnCollectionReseting()
Declaration
protected bool OnCollectionReseting()
Returns
System.
|
OnNotifyPropertyChanged(PropertyChangedEventArgs)
Raises the NotifyPropertyChanged event
Declaration
protected virtual void OnNotifyPropertyChanged(PropertyChangedEventArgs e)
Parameters
System. A System. |
OnNotifyPropertyChanged(String)
Raises the PropertyChanged event
Declaration
protected virtual void OnNotifyPropertyChanged(string propertyName)
Parameters
System. The name of the property |
OnNotifyPropertyChanging(String)
Raises the PropertyChanging event
Declaration
protected virtual void OnNotifyPropertyChanging(string propertyName)
Parameters
System. The name of the property |
OnNotifyPropertyChanging(PropertyChangingEventArgsEx)
Raises the NotifyPropertyChanging event
Declaration
protected virtual void OnNotifyPropertyChanging(PropertyChangingEventArgsEx e)
Parameters
Property A System. |
RemoveItem(Int32)
Overridden. Removes the item at the specified index of the collection.
Declaration
protected override void RemoveItem(int index)
Parameters
System.
|
Overrides
RemoveRange(IEnumerable<T>)
Declaration
public virtual void RemoveRange(IEnumerable<T> items)
Parameters
System.
|
SetItem(Int32, T)
Overridden. Replaces the element at the specified index.
Declaration
protected override void SetItem(int index, T item)
Parameters
System.
|
T
item
|
Overrides
Events
CollectionChanged
Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Implements
CollectionChanging
Occurs before an item is added, removed, changed, moved, or the entire list is refreshed.
Declaration
public event NotifyCollectionChangingEventHandler CollectionChanging
Event Type
Implements
PropertyChanged
Occurs when a property of an object changes. Calling the event is developer's responsibility.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
System.
|
PropertyChanging
Occurs before a property of an object changes.
Declaration
public event PropertyChangingEventHandlerEx PropertyChanging
Event Type
Implements
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32)
Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
System.
|
System.
|
Implements
ICollection.Count
Declaration
int ICollection.Count { get; }
Returns
System.
|
Implements
ICollection.IsSynchronized
Declaration
bool ICollection.IsSynchronized { get; }
Returns
System.
|
Implements
ICollection.SyncRoot
Declaration
object ICollection.SyncRoot { get; }
Returns
System.
|
Implements
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
System.
|
Implements
IList.Add(Object)
Declaration
int IList.Add(object value)
Parameters
System.
|
Returns
System.
|
Implements
IList.Clear()
Declaration
void IList.Clear()
Implements
IList.Contains(Object)
Declaration
bool IList.Contains(object value)
Parameters
System.
|
Returns
System.
|
Implements
IList.get_Item(Int32)
Declaration
object IList.get_Item(int index)
Parameters
System.
|
Returns
System.
|
Implements
IList.IndexOf(Object)
Declaration
int IList.IndexOf(object value)
Parameters
System.
|
Returns
System.
|
Implements
IList.Insert(Int32, Object)
Declaration
void IList.Insert(int index, object value)
Parameters
System.
|
System.
|
Implements
IList.IsFixedSize
Declaration
bool IList.IsFixedSize { get; }
Returns
System.
|
Implements
IList.IsReadOnly
Declaration
bool IList.IsReadOnly { get; }
Returns
System.
|
Implements
IList.Item[Int32]
Declaration
object IList.this[] { get; set; }
Parameters
System.
|
Returns
System.
|
Implements
IList.Remove(Object)
Declaration
void IList.Remove(object value)
Parameters
System.
|
Implements
IList.RemoveAt(Int32)
Declaration
void IList.RemoveAt(int index)
Parameters
System.
|
Implements
IList.set_Item(Int32, Object)
Declaration
void IList.set_Item(int index, object value)
Parameters
System.
|
System.
|