Export (0) Print
Expand All

UIElementCollection Class

Represents an ordered collection of UIElement child elements.

System::Object
  System.Windows.Controls::UIElementCollection

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public ref class UIElementCollection : IList, 
	ICollection, IEnumerable

The UIElementCollection type exposes the following members.

  NameDescription
Public methodUIElementCollectionInitializes a new instance of the UIElementCollection class.
Top

  NameDescription
Public propertyCapacityGets or sets the number of elements that the UIElementCollection can contain.
Public propertyCountGets the actual number of elements in the collection.
Public propertyIsSynchronizedGets a value that indicates whether access to the ICollection interface is synchronized (thread-safe).
Public propertyItemGets or sets the UIElement stored at the zero-based index position of the UIElementCollection.
Public propertySyncRootGets an object that you can use to synchronize access to the ICollection interface.
Top

  NameDescription
Public methodAddAdds the specified element to the UIElementCollection.
Public methodClearRemoves all elements from a UIElementCollection.
Protected methodClearLogicalParentClears the logical parent of an element when the element leaves a UIElementCollection.
Public methodContainsDetermines whether a specified element is in the UIElementCollection.
Public methodCopyTo(Array, Int32)Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.
Public methodCopyTo(array<UIElement>, Int32)Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that can iterate the UIElementCollection.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfReturns the index position of a specified element in a UIElementCollection.
Public methodInsertInserts an element into a UIElementCollection at the specified index position.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the specified element from a UIElementCollection.
Public methodRemoveAtRemoves the UIElement at the specified index.
Public methodRemoveRangeRemoves a range of elements from a UIElementCollection.
Protected methodSetLogicalParentSets the logical parent of an element in a UIElementCollection.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<TResult>Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIList::AddThis 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.
Explicit interface implemetationPrivate methodIList::ContainsThis 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.
Explicit interface implemetationPrivate methodIList::IndexOfThis 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.
Explicit interface implemetationPrivate methodIList::InsertThis 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.
Explicit interface implemetationPrivate propertyIList::IsFixedSizeThis 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.
Explicit interface implemetationPrivate propertyIList::IsReadOnlyThis 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.
Explicit interface implemetationPrivate propertyIList::ItemThis 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.
Explicit interface implemetationPrivate methodIList::RemoveThis 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.
Top

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft