UIElementCollection
UIElementCollection
UIElementCollection
UIElementCollection
Class
Definition
public : sealed class UIElementCollection
struct winrt::Windows::UI::Xaml::Controls::UIElementCollection
public sealed class UIElementCollection
Public NotInheritable Class UIElementCollection
<panelobject>
oneOrMoreChildren
</panelobject>
- Attributes
Windows 10 requirements
Device family |
Windows 10 (introduced v10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
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.
Enumerating the collection in C# or Microsoft Visual Basic
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
Properties
Size Size Size Size |
Gets the size (count) of the collection. |
Methods
See also
Feedback
Loading feedback...