In This Article

SimpleObservableCollection<T> Class

Provides a generic collection that provides notifications when items are added or removed.

public class SimpleObservableCollection<T> : Collection<T> where T : class
Type Parameters:
T -

The type of collection item.

Inheritance:
object Collection<T> object
Derived:
StructureMatchResultCollection LexicalScopeCollection SearchPatternProviderCollection KeyedObservableCollection<T> SimpleSynchronizedCollection<T>

Constructors

SimpleObservableCollection()

Initializes an instance of the class.

public SimpleObservableCollection()

Properties

IsReadOnly

Gets whether the collection is allowed to be modified.

public virtual bool IsReadOnly { get; }

Property Value

bool:

true if the collection is allowed to be modified; otherwise, false.

Methods

BlockReentrancy()

Disallows reentrant attempts to change this collection.

protected IDisposable BlockReentrancy()

Returns

IDisposable:

An IDisposable object that can be used to dispose of the object.

CheckReadOnly()

Throws an exception if the collection is read-only.

protected virtual void CheckReadOnly()

CheckReentrancy()

Checks for reentrant attempts to change this collection.

protected void CheckReentrancy()

ClearItems()

Removes all items from the collection.

protected override void ClearItems()

InsertItem(int, T)

Inserts an item into the collection at the specified index.

protected override void InsertItem(int index, T item)
Parameter Type Description
index int

The index at which to insert the item.

item T

The item to insert.

OnItemAdded(int, T)

Called after an item as been added into the collection.

protected virtual void OnItemAdded(int index, T value)
Parameter Type Description
index int

The index at which the item is added.

value T

The item that is added.

OnItemAdding(int, T)

Called before an item as been added into the collection.

protected virtual void OnItemAdding(int index, T value)
Parameter Type Description
index int

The index at which the item is added.

value T

The item that is added.

OnItemRemoved(int, T)

Called after an item has been removed from the collection.

protected virtual void OnItemRemoved(int index, T value)
Parameter Type Description
index int

The index at which the item is removed.

value T

The item that is removed.

OnItemRemoving(int, T)

Called before an item has been removed from the collection.

protected virtual void OnItemRemoving(int index, T value)
Parameter Type Description
index int

The index at which the item is removed.

value T

The item that is removed.

RemoveItem(int)

Removes the item at the specified index.

protected override void RemoveItem(int index)
Parameter Type Description
index int

The index of the item to remove.

SetItem(int, T)

Replaces the item at the specified index.

protected override void SetItem(int index, T item)
Parameter Type Description
index int

The index of the item to replace.

item T

The item with which to replace.

Events

ItemAdded

Occurs after an item is added to the collection.

public event EventHandler<CollectionChangeEventArgs<T>> ItemAdded

Event Type

EventHandler<CollectionChangeEventArgs<T>>

ItemAdding

Occurs before an item is added to the collection.

public event EventHandler<CollectionChangeEventArgs<T>> ItemAdding

Event Type

EventHandler<CollectionChangeEventArgs<T>>

ItemRemoved

Occurs after an item is removed from the collection.

public event EventHandler<CollectionChangeEventArgs<T>> ItemRemoved

Event Type

EventHandler<CollectionChangeEventArgs<T>>

ItemRemoving

Occurs before an item is removed from the collection.

public event EventHandler<CollectionChangeEventArgs<T>> ItemRemoving

Event Type

EventHandler<CollectionChangeEventArgs<T>>

Inherited Members