U​IElement​Collection Class

Definition

Represents an ordered collection of UIElement child elements.

public class UIElementCollection : System.Collections.IList
Inheritance
UIElementCollection
Implements

Inherited Members

System.Object

Examples

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);
}

Remarks

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.

Constructors

U​IElement​Collection(​UI​Element, ​Framework​Element)

Initializes a new instance of the UIElementCollection class.

Properties

Capacity

Gets or sets the number of elements that the UIElementCollection can contain.

Count

Gets the actual number of elements in the collection.

Is​Synchronized

Gets a value that indicates whether access to the ICollection interface is synchronized (thread-safe).

Item(​Int32)

Gets or sets the UIElement stored at the zero-based index position of the UIElementCollection.

Sync​Root

Gets an object that you can use to synchronize access to the ICollection interface.

Methods

Add(​UI​Element)

Adds the specified element to the UIElementCollection.

Clear()

Removes all elements from a UIElementCollection.

Clear​Logical​Parent(​UI​Element)

Clears the logical parent of an element when the element leaves a UIElementCollection.

Contains(​UI​Element)

Determines whether a specified element is in the UIElementCollection.

Copy​To(​Array, ​Int32)

Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.

Copy​To(​UI​Element[], ​Int32)

Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.

Get​Enumerator()

Returns an enumerator that can iterate the UIElementCollection.

Index​Of(​UI​Element)

Returns the index position of a specified element in a UIElementCollection.

Insert(​Int32, ​UI​Element)

Inserts an element into a UIElementCollection at the specified index position.

Remove(​UI​Element)

Removes the specified element from a UIElementCollection.

Remove​At(​Int32)

Removes the UIElement at the specified index.

Remove​Range(​Int32, ​Int32)

Removes a range of elements from a UIElementCollection.

Set​Logical​Parent(​UI​Element)

Sets the logical parent of an element in a UIElementCollection.

Explicit Interface Implementations

I​List.​Add(​Object)

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(Object).

I​List.​Contains(​Object)

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(Object).

I​List.​Index​Of(​Object)

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(Object).

I​List.​Insert(​Int32, ​Object)

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(Int32, Object).

I​List.​Is​Fixed​Size

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.

I​List.​Is​Read​Only

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.

I​List.​Item(​Int32)

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(Int32).

I​List.​Remove(​Object)

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(Object).

Extension Methods

Cast<TResult>(IEnumerable)

Represents an ordered collection of UIElement child elements.

OfType<TResult>(IEnumerable)

Represents an ordered collection of UIElement child elements.

AsParallel(IEnumerable)

Represents an ordered collection of UIElement child elements.

AsQueryable(IEnumerable)

Represents an ordered collection of UIElement child elements.