Class DependencyObjectCollection<T>
Represents a collection of DependencyObject instances of a specified type.
Inheritance
Implements
Inherited Members
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public class DependencyObjectCollection<T> : DependencyObject, IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged
Type Parameters
Name | Description |
---|---|
T | The type of items in the collection. |
Constructors
| Improve this Doc View SourceDependencyObjectCollection()
Initializes a new instance of the DependencyObjectCollection<T> class.
Declaration
public DependencyObjectCollection()
Properties
| Improve this Doc View SourceCount
Gets the number of objects in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Gets a value that indicates whether the collection can be modified.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 index of the object to get or set. |
Property Value
Type | Description |
---|---|
T | The object at the specified index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is less than zero or greater than the number of items in the collection. |
System.ArgumentException | The specified value when setting this property is not a DependencyObject. |
System.InvalidOperationException | The property is being set in a CollectionChanged event handler. |
Methods
| Improve this Doc View SourceAdd(T)
Adds the specified object to the end of the collection.
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to add to the collection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | item is not a DependencyObject. |
System.InvalidOperationException | The method is being called in a CollectionChanged event handler. |
Clear()
Removes all objects from the collection.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The method is being called in a CollectionChanged event handler. |
Contains(T)
Gets a value that indicates whether the specified object is in the collection.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to check for in the collection. |
Returns
Type | Description |
---|---|
System.Boolean | true if the object is in the collection; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | item is not a DependencyObject. |
CopyTo(T[], Int32)
Copies the objects in the collection to the specified array, starting at the specified index.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The destination array. |
System.Int32 | arrayIndex | The index of the first object to copy. |
GetEnumerator()
Gets an enumerator that iterates through the collection.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> | An enumerator for the collection. |
IndexOf(T)
Gets the index of the specified object within the collection, or -1 if the object is not in the 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 index of the first occurrence of item within the collection, or -1 if item is not in the collection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | item is not a DependencyObject. |
Insert(Int32, T)
Adds the specified object to the collection at the specified index.
Declaration
public void Insert(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index at which to add the object. |
T | item | The object to add. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is less than zero or greater than the number of items in the collection. |
System.ArgumentException | item is not a DependencyObject. |
System.InvalidOperationException | The method is being called in a CollectionChanged event handler. |
Remove(T)
Removes the specified object from the collection.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if the object was removed; false if the object was not found in the collection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | item is not a DependencyObject. |
System.InvalidOperationException | The method is being called in a CollectionChanged event handler. |
RemoveAt(Int32)
Removes the object at the specified index from the collection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the object to remove. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is less than zero or greater than the highest index in the collection. |
System.InvalidOperationException | The method is being called in a CollectionChanged event handler. |
Events
| Improve this Doc View SourceCollectionChanged
Occurs when items in the collection are added, removed, or replaced.
Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Type | Description |
---|---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |
Explicit Interface Implementations
| Improve this Doc View SourceICollection.CopyTo(Array, Int32)
Declaration
void ICollection.CopyTo(Array array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | |
System.Int32 | arrayIndex |
ICollection.IsSynchronized
Declaration
bool ICollection.IsSynchronized { get; }
Returns
Type | Description |
---|---|
System.Boolean |
ICollection.SyncRoot
Declaration
object ICollection.SyncRoot { get; }
Returns
Type | Description |
---|---|
System.Object |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
IList.Add(Object)
Declaration
int IList.Add(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item |
Returns
Type | Description |
---|---|
System.Int32 |
IList.Contains(Object)
Declaration
bool IList.Contains(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item |
Returns
Type | Description |
---|---|
System.Boolean |
IList.IndexOf(Object)
Declaration
int IList.IndexOf(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.Int32 |
IList.Insert(Int32, Object)
Declaration
void IList.Insert(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
System.Object | value |
IList.IsFixedSize
Declaration
bool IList.IsFixedSize { get; }
Returns
Type | Description |
---|---|
System.Boolean |
IList.Item[Int32]
Declaration
object IList.this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type | Description |
---|---|
System.Object |
IList.Remove(Object)
Declaration
void IList.Remove(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |