UIElementCollection Class
Represents an ordered collection of UIElement child elements.
Assembly: PresentationFramework (in PresentationFramework.dll)
The UIElementCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Capacity | Gets or sets the number of elements that the UIElementCollection can contain. |
![]() | Count | Gets the actual number of elements in the collection. |
![]() | IsSynchronized | Gets a value that indicates whether access to the ICollection interface is synchronized (thread-safe). |
![]() | Item | Gets or sets the UIElement stored at the zero-based index position of the UIElementCollection. |
![]() | SyncRoot | Gets an object that you can use to synchronize access to the ICollection interface. |
| Name | Description | |
|---|---|---|
![]() | Add | Adds the specified element to the UIElementCollection. |
![]() | Clear | Removes all elements from a UIElementCollection. |
![]() | ClearLogicalParent | Clears the logical parent of an element when the element leaves a UIElementCollection. |
![]() | Contains | Determines whether a specified element is in the UIElementCollection. |
![]() | CopyTo(Array, Int32) | Copies a UIElement from a UIElementCollection to an array, starting at a specified index position. |
![]() | CopyTo(array<UIElement>, Int32) | Copies a UIElement from a UIElementCollection to an array, starting at a specified index position. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetEnumerator | Returns an enumerator that can iterate the UIElementCollection. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IndexOf | Returns the index position of a specified element in a UIElementCollection. |
![]() | Insert | Inserts an element into a UIElementCollection at the specified index position. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Remove | Removes the specified element from a UIElementCollection. |
![]() | RemoveAt | Removes the UIElement at the specified index. |
![]() | RemoveRange | Removes a range of elements from a UIElementCollection. |
![]() | SetLogicalParent | Sets the logical parent of an element in a UIElementCollection. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | AsParallel | Enables parallelization of a query. (Defined by ParallelEnumerable.) |
![]() | AsQueryable | Converts an IEnumerable to an IQueryable. (Defined by Queryable.) |
![]() | Cast<TResult> | Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.) |
![]() | OfType<TResult> | Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.) |
| Name | Description | |
|---|---|---|
![]() ![]() | IList::Add | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see Add. |
![]() ![]() | IList::Contains | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see Contains. |
![]() ![]() | IList::IndexOf | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see IndexOf. |
![]() ![]() | IList::Insert | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see Insert. |
![]() ![]() | IList::IsFixedSize | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see IsFixedSize. |
![]() ![]() | IList::IsReadOnly | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see IsReadOnly. |
![]() ![]() | IList::Item | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see Item. |
![]() ![]() | IList::Remove | This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see Remove. |
The Panel base class uses a UIElementCollection to represent its collection of child elements. Methods and properties defined by the UIElementCollection affect all objects derived from Panel and define a common feature-set for the manipulation of Panel child elements.
A UIElementCollection has affinity to its own context (class). You must access the collection from the context of the owning Panel.
The following example uses the Add method to add child content to a parent StackPanel. You do this by using the Children property, which is of type UIElementCollection.
void AddButton(object sender, MouseButtonEventArgs e) { sp1.Children.Clear(); btn = new Button(); btn.Content = "New Button"; sp1.Children.Add(btn); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

