Class UIElementCollection
A UIElementCollection is a ordered collection of UIElements.
Inherited Members
Namespace: nanoFramework.Presentation
Assembly: nanoFramework.Graphics.dll
Syntax
public class UIElementCollection : ICollection, IEnumerable
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)
Declaration
public UIElementCollection(UIElement owner)
Parameters
Type | Name | Description |
---|---|---|
UIElement | owner |
Properties
Capacity
Gets or sets the number of elements that the UIElementCollection can contain.
Declaration
public virtual int Capacity { get; set; }
Property Value
Type | Description |
---|---|
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
Type | Condition |
---|---|
ArgumentOutOfRangeException | Capacity is set to a value that is less than Count. |
Count
Declaration
public virtual int Count { get; }
Property Value
Type | Description |
---|---|
int |
IsSynchronized
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
bool |
this[int]
Indexer for the UIElementCollection. Gets or sets the UIElement stored at the zero-based index of the UIElementCollection.
Declaration
public UIElement this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index |
Property Value
Type | Description |
---|---|
UIElement |
Remarks
This property provides the ability to access a specific UIElement in the
UIElementCollection by using the following systax: myUIElementCollection[index]
.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentException | If the new child has already a parent or if the slot a the specified index is not null. |
SyncRoot
Declaration
public virtual object SyncRoot { get; }
Property Value
Type | Description |
---|---|
object |
Methods
Add(UIElement)
Appends a UIElement to the end of the UIElementCollection.
Declaration
public int Add(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element |
Returns
Type | Description |
---|---|
int | The UIElementCollection index at which the UIElement has been added. |
Remarks
Adding a null is allowed.
Exceptions
Type | Condition |
---|---|
ArgumentException | If the new child has already a parent. |
Clear()
Removes all elements from the UIElementCollection.
Declaration
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.
Declaration
public bool Contains(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element |
Returns
Type | Description |
---|---|
bool |
CopyTo(UIElement[], int)
Strongly typed version of CopyTo Copies the collection into the Array.
Declaration
public virtual void CopyTo(UIElement[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
UIElement[] | array | |
int | index |
CopyTo(Array, int)
Copies the UIElement collection to the specified array starting at the specified index.
Declaration
public void CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
Array | array | |
int | index |
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.
Declaration
public int IndexOf(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element |
Returns
Type | Description |
---|---|
int |
Insert(int, UIElement)
Inserts an element into the UIElementCollection at the specified index.
Declaration
public void Insert(int index, UIElement element)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index at which value should be inserted. |
UIElement | element | The 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
Type | Condition |
---|---|
ArgumentOutOfRangeException | index is less than zero. -or- index is greater than Count. |
Remove(UIElement)
Removes the specified element from the UIElementCollection.
Declaration
public void Remove(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The 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.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The 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
Type | Condition |
---|---|
ArgumentOutOfRangeException | index is less than zero
|
RemoveRange(int, int)
Removes a range of UIElements from the UIElementCollection.
Declaration
public void RemoveRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the range of elements to remove |
int | count | The 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
Type | Condition |
---|---|
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. |