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.Collections.Generic.IEnumerable<T>
list
|
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.Collections.Generic.IList<T>
list
|
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
ObservableCollection<T>
list
|
Fields
CountString
Declaration
protected const string CountString = "Count"
Field Value
System.String
|
ItemArrayString
Declaration
protected const string ItemArrayString = "Item[]"
Field Value
System.String
|
Properties
IsUpdated
true to indicate the collection has completed update; otherwise false.
Declaration
public bool IsUpdated { get; }
Property Value
System.Boolean
|
Methods
AddRange(IEnumerable<T>)
Declaration
public virtual void AddRange(IEnumerable<T> items)
Parameters
System.Collections.Generic.IEnumerable<T>
items
|
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.Object
sender
|
NotifyCollectionChangedEventArgs
e
|
CallCollectionChanging(Object, NotifyCollectionChangingEventArgs)
Declaration
protected void CallCollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
Parameters
System.Object
sender
|
NotifyCollectionChangingEventArgs
e
|
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.Boolean
notifyUpdates
|
EndUpdate()
Declaration
public void EndUpdate()
EndUpdate(Boolean)
Resumes event notification.
Declaration
public virtual void EndUpdate(bool notifyUpdates)
Parameters
System.Boolean
notifyUpdates
|
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.Int32
index
|
T
item
|
Overrides
InsertItem(Int32, T, Action<T>)
Declaration
protected virtual void InsertItem(int index, T item, Action<T> approvedAction)
Parameters
System.Int32
index
|
T
item
|
System.Action<T>
approvedAction
|
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.Int32
oldIndex
|
System.Int32
newIndex
|
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.Int32
oldIndex
|
System.Int32
newIndex
|
NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs)
Raises the CollectionChanged event with the provided arguments.
Declaration
protected virtual void NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
NotifyCollectionChangedEventArgs
e
|
NotifyListenersCollectionChanging(NotifyCollectionChangingEventArgs)
Raises the CollectionChanging event with the provided arguments.
Declaration
protected virtual void NotifyListenersCollectionChanging(NotifyCollectionChangingEventArgs e)
Parameters
NotifyCollectionChangingEventArgs
e
|
OnCollectionChanged(NotifyCollectionChangedAction, Object, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
item
|
System.Int32
index
|
OnCollectionChanged(NotifyCollectionChangedAction, Object, Int32, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
item
|
System.Int32
index
|
System.Int32
oldIndex
|
OnCollectionChanged(NotifyCollectionChangedAction, Object, Object, Int32)
Declaration
protected void OnCollectionChanged(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
oldItem
|
System.Object
newItem
|
System.Int32
index
|
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Calls the NotifyListenersCollectionChanged method with the provided arguments if not in a batch update.
Declaration
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
NotifyCollectionChangedEventArgs
e
|
OnCollectionChanging(NotifyCollectionChangedAction, Object, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
item
|
System.Int32
index
|
Returns
System.Boolean
|
OnCollectionChanging(NotifyCollectionChangedAction, Object, Int32, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object item, int index, int oldIndex)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
item
|
System.Int32
index
|
System.Int32
oldIndex
|
Returns
System.Boolean
|
OnCollectionChanging(NotifyCollectionChangedAction, Object, Object, Int32)
Declaration
protected bool OnCollectionChanging(NotifyCollectionChangedAction action, object oldItem, object newItem, int index)
Parameters
NotifyCollectionChangedAction
action
|
System.Object
oldItem
|
System.Object
newItem
|
System.Int32
index
|
Returns
System.Boolean
|
OnCollectionChanging(NotifyCollectionChangingEventArgs)
Calls the NotifyListenersCollectionChanging method with the provided arguments if not in a batch update.
Declaration
protected virtual bool OnCollectionChanging(NotifyCollectionChangingEventArgs e)
Parameters
NotifyCollectionChangingEventArgs
e
|
Returns
System.Boolean
|
OnCollectionReset(IList)
Declaration
protected void OnCollectionReset(IList oldItems)
Parameters
System.Collections.IList
oldItems
|
OnCollectionReseting()
Declaration
protected bool OnCollectionReseting()
Returns
System.Boolean
|
OnNotifyPropertyChanged(PropertyChangedEventArgs)
Raises the NotifyPropertyChanged event
Declaration
protected virtual void OnNotifyPropertyChanged(PropertyChangedEventArgs e)
Parameters
System.ComponentModel.PropertyChangedEventArgs
e
A System.ComponentModel.PropertyChangedEventArgs instance containing event data. |
OnNotifyPropertyChanged(String)
Raises the PropertyChanged event
Declaration
protected virtual void OnNotifyPropertyChanged(string propertyName)
Parameters
System.String
propertyName
The name of the property |
OnNotifyPropertyChanging(String)
Raises the PropertyChanging event
Declaration
protected virtual void OnNotifyPropertyChanging(string propertyName)
Parameters
System.String
propertyName
The name of the property |
OnNotifyPropertyChanging(PropertyChangingEventArgsEx)
Raises the NotifyPropertyChanging event
Declaration
protected virtual void OnNotifyPropertyChanging(PropertyChangingEventArgsEx e)
Parameters
PropertyChangingEventArgsEx
e
A System.ComponentModel.PropertyChangingEventArgs instance containing event data. |
RemoveItem(Int32)
Overridden. Removes the item at the specified index of the collection.
Declaration
protected override void RemoveItem(int index)
Parameters
System.Int32
index
|
Overrides
RemoveRange(IEnumerable<T>)
Declaration
public virtual void RemoveRange(IEnumerable<T> items)
Parameters
System.Collections.Generic.IEnumerable<T>
items
|
SetItem(Int32, T)
Overridden. Replaces the element at the specified index.
Declaration
protected override void SetItem(int index, T item)
Parameters
System.Int32
index
|
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
NotifyCollectionChangedEventHandler
|
Implements
CollectionChanging
Occurs before an item is added, removed, changed, moved, or the entire list is refreshed.
Declaration
public event NotifyCollectionChangingEventHandler CollectionChanging
Event Type
NotifyCollectionChangingEventHandler
|
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.ComponentModel.PropertyChangedEventHandler
|
PropertyChanging
Occurs before a property of an object changes.
Declaration
public event PropertyChangingEventHandlerEx PropertyChanging
Event Type
PropertyChangingEventHandlerEx
|
Implements
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32)
Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
System.Array
array
|
System.Int32
index
|
Implements
ICollection.Count
Declaration
int ICollection.Count { get; }
Returns
System.Int32
|
Implements
ICollection.IsSynchronized
Declaration
bool ICollection.IsSynchronized { get; }
Returns
System.Boolean
|
Implements
ICollection.SyncRoot
Declaration
object ICollection.SyncRoot { get; }
Returns
System.Object
|
Implements
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
System.Collections.IEnumerator
|
Implements
IList.Add(Object)
Declaration
int IList.Add(object value)
Parameters
System.Object
value
|
Returns
System.Int32
|
Implements
IList.Clear()
Declaration
void IList.Clear()
Implements
IList.Contains(Object)
Declaration
bool IList.Contains(object value)
Parameters
System.Object
value
|
Returns
System.Boolean
|
Implements
IList.get_Item(Int32)
Declaration
object IList.get_Item(int index)
Parameters
System.Int32
index
|
Returns
System.Object
|
Implements
IList.IndexOf(Object)
Declaration
int IList.IndexOf(object value)
Parameters
System.Object
value
|
Returns
System.Int32
|
Implements
IList.Insert(Int32, Object)
Declaration
void IList.Insert(int index, object value)
Parameters
System.Int32
index
|
System.Object
value
|
Implements
IList.IsFixedSize
Declaration
bool IList.IsFixedSize { get; }
Returns
System.Boolean
|
Implements
IList.IsReadOnly
Declaration
bool IList.IsReadOnly { get; }
Returns
System.Boolean
|
Implements
IList.Item[Int32]
Declaration
object IList.this[] { get; set; }
Parameters
System.Int32
index
|
Returns
System.Object
|
Implements
IList.Remove(Object)
Declaration
void IList.Remove(object value)
Parameters
System.Object
value
|
Implements
IList.RemoveAt(Int32)
Declaration
void IList.RemoveAt(int index)
Parameters
System.Int32
index
|
Implements
IList.set_Item(Int32, Object)
Declaration
void IList.set_Item(int index, object value)
Parameters
System.Int32
index
|
System.Object
value
|