Show / Hide Table of Contents

Class ObservableCollection<T>

Represent a collection of items that fire events when it is modified.

Inheritance
System.Object
ObservableCollection<T>
Implements
System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: netDxf.Collections
Assembly: CADability.dll
Syntax
public class ObservableCollection<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name Description
T

Type of items.

Constructors

| Improve this Doc View Source

ObservableCollection()

Initializes a new instance of ObservableCollection.

Declaration
public ObservableCollection()
| Improve this Doc View Source

ObservableCollection(Int32)

Initializes a new instance of ObservableCollection and has the specified initial capacity.

Declaration
public ObservableCollection(int capacity)
Parameters
Type Name Description
System.Int32 capacity

The number of items the collection can initially store.

Properties

| Improve this Doc View Source

Count

Gets the number of object contained in the collection.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

IsReadOnly

Gets a value indicating whether the collection is read-only.

Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Item[Int32]

Gets or sets the object 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 object at the specified index.

Methods

| Improve this Doc View Source

Add(T)

Adds an object to the collection.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The object to add to the collection.

| Improve this Doc View Source

AddRange(IEnumerable<T>)

Adds an object list to the end of the collection.

Declaration
public void AddRange(IEnumerable<T> collection)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> collection

The collection whose elements should be added.

| Improve this Doc View Source

Clear()

Removes all object from the collection.

Declaration
public void Clear()
| Improve this Doc View Source

Contains(T)

Determines whether an object is in the collection.

Declaration
public bool Contains(T item)
Parameters
Type Name Description
T item

The object to locate in the collection.

Returns
Type Description
System.Boolean

True if item is found in the collection; otherwise, false.

| Improve this Doc View Source

CopyTo(T[], Int32)

Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.

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 the collection. The System.Array must have zero-based indexing.

System.Int32 arrayIndex

The zero-based index in array at which copying begins.

| Improve this Doc View Source

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>

An enumerator that can be used to iterate through the collection.

| Improve this Doc View Source

IndexOf(T)

Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.

Declaration
public int IndexOf(T item)
Parameters
Type Name Description
T item

The object to locate in the collection.

Returns
Type Description
System.Int32

The zero-based index of the first occurrence of item within the entire collection, if found; otherwise, –1.

| Improve this Doc View Source

Insert(Int32, T)

Inserts an object into the collection 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. The value can not be null.

| Improve this Doc View Source

OnAddItemEvent(T)

Declaration
protected virtual void OnAddItemEvent(T item)
Parameters
Type Name Description
T item
| Improve this Doc View Source

OnBeforeAddItemEvent(T)

Declaration
protected virtual bool OnBeforeAddItemEvent(T item)
Parameters
Type Name Description
T item
Returns
Type Description
System.Boolean
| Improve this Doc View Source

OnBeforeRemoveItemEvent(T)

Declaration
protected virtual bool OnBeforeRemoveItemEvent(T item)
Parameters
Type Name Description
T item
Returns
Type Description
System.Boolean
| Improve this Doc View Source

OnRemoveItemEvent(T)

Declaration
protected virtual void OnRemoveItemEvent(T item)
Parameters
Type Name Description
T item
| Improve this Doc View Source

Remove(T)

Removes the first occurrence of a specific object from the collection

Declaration
public bool Remove(T item)
Parameters
Type Name Description
T item

The object to remove from the collection.

Returns
Type Description
System.Boolean

True if object is successfully removed; otherwise, false.

| Improve this Doc View Source

Remove(IEnumerable<T>)

Removes the first occurrence of a specific object from the collection

Declaration
public void Remove(IEnumerable<T> items)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

The list of objects to remove from the collection.

| Improve this Doc View Source

RemoveAt(Int32)

Removes the object at the specified index of the collection.

Declaration
public void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

The zero-based index of the object to remove.

| Improve this Doc View Source

Reverse()

Reverses the order of the elements in the entire list.

Declaration
public void Reverse()
| Improve this Doc View Source

Sort()

Sorts the elements in the entire System.Collections.Generic.List<T> using the default comparer.

Declaration
public void Sort()
| Improve this Doc View Source

Sort(IComparer<T>)

Sorts the elements in a range of elements in System.Collections.Generic.List<T> using the specified comparer.

Declaration
public void Sort(IComparer<T> comparer)
Parameters
Type Name Description
System.Collections.Generic.IComparer<T> comparer

The System.Collections.Generic.IComparer<T> implementation to use when comparing elements, or null to use the default comparer System.Collections.Generic.Comparer<T>.Default.

| Improve this Doc View Source

Sort(Comparison<T>)

Sorts the elements in the entire System.Collections.Generic.List<T> using the specified System.Comparison<T>.

Declaration
public void Sort(Comparison<T> comparision)
Parameters
Type Name Description
System.Comparison<T> comparision

The System.Comparison<T> to use when comparing elements.

| Improve this Doc View Source

Sort(Int32, Int32, IComparer<T>)

Sorts the elements in a range of elements in System.Collections.Generic.List<T> using the specified comparer.

Declaration
public void Sort(int index, int count, IComparer<T> comparer)
Parameters
Type Name Description
System.Int32 index

The zero-based starting index of the range to sort.

System.Int32 count

The length of the range to sort.

System.Collections.Generic.IComparer<T> comparer

The System.Collections.Generic.IComparer<T> implementation to use when comparing elements, or null to use the default comparer System.Collections.Generic.Comparer<T>.Default.

Events

| Improve this Doc View Source

AddItem

Declaration
public event ObservableCollection<T>.AddItemEventHandler AddItem
Event Type
Type Description
ObservableCollection.AddItemEventHandler<>
| Improve this Doc View Source

BeforeAddItem

Declaration
public event ObservableCollection<T>.BeforeAddItemEventHandler BeforeAddItem
Event Type
Type Description
ObservableCollection.BeforeAddItemEventHandler<>
| Improve this Doc View Source

BeforeRemoveItem

Declaration
public event ObservableCollection<T>.BeforeRemoveItemEventHandler BeforeRemoveItem
Event Type
Type Description
ObservableCollection.BeforeRemoveItemEventHandler<>
| Improve this Doc View Source

RemoveItem

Declaration
public event ObservableCollection<T>.RemoveItemEventHandler RemoveItem
Event Type
Type Description
ObservableCollection.RemoveItemEventHandler<>

Explicit Interface Implementations

| Improve this Doc View Source

ICollection<T>.Add(T)

Declaration
void ICollection<T>.Add(T item)
Parameters
Type Name Description
T item
| Improve this Doc View Source

IList<T>.Insert(Int32, T)

Declaration
void IList<T>.Insert(int index, T item)
Parameters
Type Name Description
System.Int32 index
T item
| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX