This topic has not yet been rated - Rate this topic

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 class UIElementCollection : IList, 
	ICollection, IEnumerable

The UIElementCollection type exposes the following members.

  Name Description
Public method UIElementCollection Initializes a new instance of the UIElementCollection class.
Top
  Name Description
Public property Capacity Gets or sets the number of elements that the UIElementCollection can contain.
Public property Count Gets the actual number of elements in the collection.
Public property IsSynchronized Gets a value that indicates whether access to the ICollection interface is synchronized (thread-safe).
Public property Item Gets or sets the UIElement stored at the zero-based index position of the UIElementCollection.
Public property SyncRoot Gets an object that you can use to synchronize access to the ICollection interface.
Top
  Name Description
Public method Add Adds the specified element to the UIElementCollection.
Public method Clear Removes all elements from a UIElementCollection.
Protected method ClearLogicalParent Clears the logical parent of an element when the element leaves a UIElementCollection.
Public method Contains Determines whether a specified element is in the UIElementCollection.
Public method CopyTo(Array, Int32) Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.
Public method CopyTo(UIElement[], Int32) Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEnumerator Returns an enumerator that can iterate the UIElementCollection.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IndexOf Returns the index position of a specified element in a UIElementCollection.
Public method Insert Inserts an element into a UIElementCollection at the specified index position.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove Removes the specified element from a UIElementCollection.
Public method RemoveAt Removes the UIElement at the specified index.
Public method RemoveRange Removes a range of elements from a UIElementCollection.
Protected method SetLogicalParent Sets the logical parent of an element in a UIElementCollection.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public Extension Method AsParallel Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension Method AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  Name Description
Explicit interface implemetation Private method 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.
Explicit interface implemetation Private method 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.
Explicit interface implemetation Private method 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.
Explicit interface implemetation Private method 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.
Explicit interface implemetation Private property 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.
Explicit interface implemetation Private property 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.
Explicit interface implemetation Private property 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.
Explicit interface implemetation Private method 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.
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, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ