UIElementCollection Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public ref class UIElementCollection sealed : IIterable<UIElement ^>, IVector<UIElement ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UIElementCollection final : IIterable<UIElement>, IVector<UIElement>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class UIElementCollection final : IIterable<UIElement>, IVector<UIElement>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class UIElementCollection : IEnumerable<UIElement>, IList<UIElement>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class UIElementCollection : IEnumerable<UIElement>, IList<UIElement>
Public NotInheritable Class UIElementCollection
Implements IEnumerable(Of UIElement), IList(Of UIElement)
<panelobject>
oneOrMoreChildren
</panelobject>
- Inheritance
- Attributes
- Implements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
A UIElementCollection is the type of object that you get from the Children property of a Panel. For example, if you get a value from Grid.Children, that value is a UIElementCollection instance. All the properties that use a UIElementCollection in the Windows Runtime API are read-only properties, where the property is initialized with zero items when an object is first instantiated. But you can then add, remove or query items in the collection at run time, using the UIElementCollection properties and methods.
The type of the items in the UIElementCollection is constrained as UIElement. But UIElement is a base element class in Windows Runtime using XAML, so there are hundreds of element types that can be treated as a UIElement and can thus be one of the items in a UIElementCollection.
A UIElementCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the UIElementCollection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<UIElement>
explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a UIElement constraint.
Size |
Gets the size (count) of the collection. |
Append(UIElement) |
Adds a new item to the collection. |
Clear() |
Removes all items from the collection. |
First() |
Returns the iterator object that can iterate over the items in the UIElementCollection. |
Get |
Returns the item located at the specified index. |
Get |
Retrieves multiple elements in a single pass through the iterator. |
Get |
Gets an immutable view into the collection. |
Index |
Retrieves the index of the specified item. |
Insert |
Inserts the specified item at the specified index. |
Move(UInt32, UInt32) |
Moves the item at the specified index to a new location in the collection. |
Remove |
Removes the item at the specified index. |
Remove |
Removes the last item in the collection. |
Replace |
Initially clears the collection, then inserts the provided array as new items. |
Set |
Sets the value at the specified index to the UIElement value specified. |