Class UIElementCollection
- Namespace
- nanoFramework.Presentation
- Assembly
- nanoFramework.Graphics.dll
A UIElementCollection is a ordered collection of UIElements.
public class UIElementCollection : ICollection, IEnumerable
- Inheritance
-
UIElementCollection
- Implements
- Inherited Members
- Extension Methods
Remarks
A UIElementCollection has implied context affinity. It is a violation to access the collection from a different context than that of the owning Element
This collection is an amalgam of UIElementCollection and UIElementCollection from Avalon
Constructors
UIElementCollection(UIElement)
Represents a collection of UIElement objects.
public UIElementCollection(UIElement owner)
Parameters
owner
UIElement
Properties
Capacity
Gets or sets the number of elements that the UIElementCollection can contain.
public virtual int Capacity { get; set; }
Property Value
- int
The number of elements that the UIElementCollection can contain.
Remarks
Capacity is the number of elements that the UIElementCollection is capable of storing. Count is the number of UIElements that are actually in the UIElementCollection.
Capacity is always greater than or equal to Count. If Count exceeds Capacity while adding elements, the capacity of the UIElementCollection is increased.
By default the capacity is 0.
Exceptions
- ArgumentOutOfRangeException
Capacity is set to a value that is less than Count.
Count
Gets the number of elements in the collection.
public virtual int Count { get; }
Property Value
IsSynchronized
Gets a value indicating whether access to the collection is synchronized (thread-safe).
public virtual bool IsSynchronized { get; }
Property Value
this[int]
Indexer for the UIElementCollection. Gets or sets the UIElement stored at the zero-based index of the UIElementCollection.
public UIElement this[int index] { get; set; }
Parameters
index
intThe zero-based index of the element to get or set.
Property Value
Remarks
This property provides the ability to access a specific UIElement in the
UIElementCollection by using the following systax: myUIElementCollection[index]
.
Exceptions
- ArgumentOutOfRangeException
index
is less than zero -or-index
is equal to or greater than Count.- ArgumentException
If the new child has already a parent or if the slot a the specified index is not null.
SyncRoot
Gets an object that can be used to synchronize access to the collection.
public virtual object SyncRoot { get; }
Property Value
Methods
Add(UIElement)
Appends a UIElement to the end of the UIElementCollection.
public int Add(UIElement element)
Parameters
element
UIElementThe UIElement to append.
Returns
- int
The UIElementCollection index at which the UIElement has been added.
Remarks
Adding a null is allowed.
Exceptions
- ArgumentException
If the new child has already a parent.
Clear()
Removes all elements from the UIElementCollection.
public void Clear()
Remarks
Count is set to zero. Capacity remains unchanged. To reset the capacity of the UIElementCollection, call TrimToSize or set the Capacity property directly.
Contains(UIElement)
Determines whether a element is in the UIElementCollection.
public bool Contains(UIElement element)
Parameters
element
UIElement
Returns
CopyTo(Array, int)
Copies the UIElement collection to the specified array starting at the specified index.
public void CopyTo(Array array, int index)
Parameters
array
ArrayThe one-dimensional Array that is the destination of the elements copied from UIElementCollection. The Array must have zero-based indexing.
index
intThe zero-based index in array at which copying begins.
CopyTo(UIElement[], int)
Strongly typed version of CopyTo Copies the collection into the Array.
public virtual void CopyTo(UIElement[] array, int index)
Parameters
array
UIElement[]The array to copy the collection to.
index
intThe index in the array at which to start copying.
IndexOf(UIElement)
Returns the zero-based index of the UIElement. If the UIElement is not in the UIElementCollection -1 is returned. If null is passed to the method, the index of the first entry with null is returned. If there is no null entry -1 is returned.
public int IndexOf(UIElement element)
Parameters
element
UIElement
Returns
Insert(int, UIElement)
Inserts an element into the UIElementCollection at the specified index.
public void Insert(int index, UIElement element)
Parameters
index
intThe zero-based index at which value should be inserted.
element
UIElementThe UIElement to insert.
Remarks
If Count already equals Capacity, the capacity of the UIElementCollection is increased before the new UIElement is inserted.
If index is equal to Count, value is added to the end of UIElementCollection.
The UIElements that follow the insertion point move down to accommodate the new UIElement. The indexes of the UIElements that are moved are also updated.
Exceptions
- ArgumentOutOfRangeException
index is less than zero.
-or-
index is greater than Count.
Remove(UIElement)
Removes the specified element from the UIElementCollection.
public void Remove(UIElement element)
Parameters
element
UIElementThe UIElement to remove from the UIElementCollection.
Remarks
The UIElements that follow the removed UIElements move up to occupy the vacated spot. The indexes of the UIElements that are moved are also updated.
If element is null then the first null entry is removed. Note that removing a null entry is linear in the size of the collection.
RemoveAt(int)
Removes the UIElement at the specified index.
public void RemoveAt(int index)
Parameters
index
intThe zero-based index of the element to remove.
Remarks
The UIElements that follow the removed UIElements move up to occupy the vacated spot. The indexes of the UIElements that are moved are also updated.
Exceptions
- ArgumentOutOfRangeException
index is less than zero - or - index is equal or greater than count.
RemoveRange(int, int)
Removes a range of UIElements from the UIElementCollection.
public void RemoveRange(int index, int count)
Parameters
index
intThe zero-based index of the range of elements to remove
count
intThe number of elements to remove.
Remarks
The UIElements that follow the removed UIElements move up to occupy the vacated spot. The indexes of the UIElements that are moved are also updated.
Exceptions
- ArgumentOutOfRangeException
index is less than zero. -or- count is less than zero.
- ArgumentException
index and count do not denote a valid range of elements in the UIElementCollection.