UIElementCollection class

Expand
This topic has not yet been rated - Rate this topic

UIElementCollection class

[This documentation is preliminary and is subject to change.]

Applies to: Metro style apps only

Represents an ordered collection of UIElement objects.

Inheritance

Object
  UIElementCollection

Syntax


public sealed class UIElementCollection : Object,
    IList<UIElement>,
    IEnumerable<UIElement>


<panelobject>
  oneOrMoreChildren
</panelobject>

XAML Values

oneOrMoreChildren

One or more objects elements for classes that derive from UIElement.

panelobject

Object element (opening and closing tags) for a class that derives from Panel. Typically this is one of the panels, such as Canvas, Grid, or StackPanel.

Attributes

MarshalingBehaviorAttribute(Agile)
ThreadingAttribute(Both)
VersionAttribute(NTDDI_WIN8)
WebHostHiddenAttribute()

Members

The UIElementCollection class has these types of members:

Methods

The UIElementCollection class has these methods. It also inherits methods from the Object class.

MethodDescription
Append Adds a new item to the collection.
Clear Removes all items from the collection.
First Returns the iterator for iteration over the items in the collection.
GetAt Returns the item located at the specified index.
GetMany Retrieves multiple elements in a single pass through the iterator.
GetView Gets an immutable view into the collection.
IndexOf Retrieves the index of the specified item.
InsertAt Inserts the specified item at the specified index.
RemoveAt Removes the item at the specified index.
RemoveAtEnd Removes the last item in the collection.
ReplaceAll Initially clears the collection, then inserts the provided array as new items.
SetAt Sets the value at the specified index to the UIElement value specified.

 

Properties

The UIElementCollection class has these properties.

PropertyAccess typeDescription

Size

Read-onlyGets the size (count) of the collection.

 

Remarks

Collection API for C# and Visual Basic

If you are writing code that accesses this collection type using C# or Visual Basic, the members shown in the class members listings are not entirely correct for C# and Visual Basic. In C# and Visual Basic, these collections support the APIs from IList<T> and IEnumerable<T>.

The following table lists the APIs that you should use to access the collection in C# or Visual Basic:

Add method
Adds an item to the collection.

Syntax: public void Add(UIElement value)

valueThe item to add to the end of the collection.

 

Contains method
Determines whether the collection contains a specific value.

Syntax: public bool Contains(UIElement item)

itemThe object to locate in the collection.
Returns true if item is found in the collection; otherwise, false.

 

CopyTo method
Copies the elements of a collection to an array, starting at a particular array index.

Syntax: public void CopyTo(UIElement[] array, int arrayIndex)

arrayThe one-dimensional array that is the destination of the elements copied from the collection.
arrayIndexThe zero-based index in array at which copying begins.

 

GetEnumerator method
Returns an enumerator that iterates through the collection.

Syntax: public IEnumerator<UIElement>.GetEnumerator()

IndexOf method
Determines the index of a specific item in the collection.

Syntax: public int IndexOf(UIElement item)

itemThe object to find in the collection.
Returns the index if found, or -1 if not found.

 

Insert method
Inserts an item into the collection at the specified index.

Syntax: public void Insert(int index, UIElement value)

indexThe zero-based index to insert at.
valueThe object to insert into the collection.

 

Remove method
Removes the first occurence of a specific object from the collection.

Syntax: public bool Remove(UIElement item)

itemThe object to remove from the collection.
Returns true if item is successfully removed from the collection; otherwise, false.

 

RemoveAt method
Removes the item at a specified index.

Syntax: public void RemoveAt(int index)

indexThe zero-based index to remove at.

 

Count property
Gets the number of elements contained in the collection.

Syntax: public int Count{get;}

Item property
Gets or sets an item in the collection by accessing its zero-based index.

Syntax: public UIElement this[int index] {get;set;}

indexThe zero-based index of the item to get or set.

 

IsReadOnly property
Gets a value that determines whether the collection is read-only.

Syntax: public bool IsReadOnly{get;}

 

Requirements

Minimum supported client

Windows 8 Release Preview

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Object
IVector(UIElement)
IIterable(UIElement)

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD