Class ObservableCollection<T>
Implements an Observable collection of Items.
Inheritance
Implements
Namespace: Cortex.Net.Types
Assembly: Cortex.Net.dll
Syntax
public sealed class ObservableCollection<T> : IList<T>, IReadOnlyList<T>, ICollection<T>, IReadOnlyCollection<T>, IList, ICollection, IEnumerable<T>, IEnumerable, IAtomProvider
Type Parameters
| Name | Description |
|---|---|
| T | The type parameter to work on. |
Constructors
| Improve this Doc View SourceObservableCollection(ISharedState, IEnhancer, IEnumerable<T>, String)
Initializes a new instance of the ObservableCollection<T> class.
Declaration
public ObservableCollection(ISharedState sharedState, IEnhancer enhancer, IEnumerable<T> initialValues, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ISharedState | sharedState | The ISharedState instance this observableCollection belongs to. |
| IEnhancer | enhancer | The IEnhancer implementation to use. |
| IEnumerable<T> | initialValues | The initial values to use. |
| System.String | name | The name of the ObservableCollection. |
ObservableCollection(ISharedState, IEnhancer, String)
Initializes a new instance of the ObservableCollection<T> class.
Declaration
public ObservableCollection(ISharedState sharedState, IEnhancer enhancer, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ISharedState | sharedState | The ISharedState instance this observableCollection belongs to. |
| IEnhancer | enhancer | The IEnhancer implementation to use. |
| System.String | name | The name of the ObservableCollection. |
Properties
| Improve this Doc View SourceCount
Gets the number of elements contained in the ObservableCollection<T>.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsFixedSize
Gets a value indicating whether the ObservableCollection<T> has a fixed size.
Declaration
public bool IsFixedSize { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsReadOnly
Gets a value indicating whether the ObservableCollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsSynchronized
Gets a value indicating whether access to the ObservableCollection<T> is synchronized (thread safe).
Declaration
public bool IsSynchronized { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[Int32]
Gets or sets the element at the specified index.
Declaration
public T this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the element to get or set. |
Property Value
| Type | Description |
|---|---|
| T | The element at the specified index. |
Name
Gets the name of the ObservableCollection<T>.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
SharedState
Gets the shared state this ObservableCollection<T> operates on.
Declaration
public ISharedState SharedState { get; }
Property Value
| Type | Description |
|---|---|
| ISharedState |
SyncRoot
Gets an object that can be used to synchronize access to the ObservableCollection<T>.
Declaration
public object SyncRoot { get; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Methods
| Improve this Doc View SourceAdd(T)
Adds an item to the ObservableCollection<T>.
Declaration
public void Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to add to the ObservableCollection<T>. |
Clear()
Removes all elements from the ObservableCollection<T>.
Declaration
public void Clear()
Contains(T)
Determines whether the ObservableCollection<T> contains a specific value.
Declaration
public bool Contains(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to locate in the ObservableCollection<T>. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if item is found in the ObservableCollection<T>; otherwise, false. |
CopyTo(T[], Int32)
Copies the elements of the ObservableCollection<T> to an System.Array, starting at a particular System.Array index.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The one-dimensional System.Array that is the destination of the elements copied from ObservableCollection<T>. The System.Array must have zero-based indexing. |
| System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
GetEnumerator()
Returns an enumerator that iterates through the ObservableCollection<T>.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<T> | An enumerator that can be used to iterate through the ObservableCollection<T>. |
IndexOf(T)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire ObservableCollection<T>.
Declaration
public int IndexOf(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to locate in the System.Collections.Generic.List`1. The value can be null for reference types. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based index of the first occurrence of item within the entire ObservableCollection<T>, if found; otherwise, –1. |
Insert(Int32, T)
Inserts an item to the ObservableCollection<T> at the specified index.
Declaration
public void Insert(int index, T item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index at which item should be inserted. |
| T | item | The object to insert into the ObservableCollection<T>. |
Remove(T)
Removes the first occurrence of a specific object from the ObservableCollection<T>.
Declaration
public bool Remove(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to remove from the ObservableCollection<T>. The value can be null for reference types. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if item is successfully removed; otherwise, false. This method also returns false if item was not found in the ObservableCollection<T>. |
RemoveAt(Int32)
Removes the ObservableCollection<T> item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the item to remove. |
Events
| Improve this Doc View SourceChange
Event that fires before the value will change.
Declaration
public event EventHandler<ObservableCollectionCancellableEventArgs> Change
Event Type
| Type | Description |
|---|---|
| EventHandler<ObservableCollectionCancellableEventArgs> |
Changed
Event that fires after the value has changed.
Declaration
public event EventHandler<ObservableCollectionEventArgs> Changed
Event Type
| Type | Description |
|---|---|
| EventHandler<ObservableCollectionEventArgs> |
Explicit Interface Implementations
| Improve this Doc View SourceIAtomProvider.Atom
Gets the atom.
Declaration
IAtom IAtomProvider.Atom { get; }
Returns
| Type | Description |
|---|---|
| IAtom |