UIElementCollection UIElementCollection UIElementCollection UIElementCollection Class

Definition

Represents an ordered collection of UIElement child elements.

public ref class UIElementCollection : System::Collections::IList
public class UIElementCollection : System.Collections.IList
type UIElementCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class UIElementCollection
Implements IList
Inheritance
UIElementCollectionUIElementCollectionUIElementCollectionUIElementCollection
Implements

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

UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement)

Initializes a new instance of the UIElementCollection class.

Properties

Capacity Capacity Capacity Capacity

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

Count Count Count Count

Gets the actual number of elements in the collection.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

SyncRoot SyncRoot SyncRoot SyncRoot

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

Methods

Add(UIElement) Add(UIElement) Add(UIElement) Add(UIElement)

Adds the specified element to the UIElementCollection.

Clear() Clear() Clear() Clear()

Removes all elements from a UIElementCollection.

ClearLogicalParent(UIElement) ClearLogicalParent(UIElement) ClearLogicalParent(UIElement) ClearLogicalParent(UIElement)

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

Contains(UIElement) Contains(UIElement) Contains(UIElement) Contains(UIElement)

Determines whether a specified element is in the UIElementCollection.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

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

CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that can iterate the UIElementCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(UIElement) IndexOf(UIElement) IndexOf(UIElement) IndexOf(UIElement)

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

Insert(Int32, UIElement) Insert(Int32, UIElement) Insert(Int32, UIElement) Insert(Int32, UIElement)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(UIElement) Remove(UIElement) Remove(UIElement) Remove(UIElement)

Removes the specified element from a UIElementCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the UIElement at the specified index.

RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32)

Removes a range of elements from a UIElementCollection.

SetLogicalParent(UIElement) SetLogicalParent(UIElement) SetLogicalParent(UIElement) SetLogicalParent(UIElement)

Sets the logical parent of an element in a UIElementCollection.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

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

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

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

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

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize 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 IList.IsReadOnly IList.IsReadOnly 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[Int32] IList.Item[Int32] IList.Item[Int32] IList.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].

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.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) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See Also