UIElementCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
type UIElementCollection = class
interface ICollection
interface IEnumerable
interface IList
Public Class UIElementCollection
Implements IList
- Inheritance
-
UIElementCollection
- 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) |
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. |
IsSynchronized |
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. |
SyncRoot |
Gets an object that you can use to synchronize access to the ICollection interface. |
Methods
Add(UIElement) |
Adds the specified element to the UIElementCollection. |
Clear() |
Removes all elements from a UIElementCollection. |
ClearLogicalParent(UIElement) |
Clears the logical parent of an element when the element leaves a UIElementCollection. |
Contains(UIElement) |
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(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) |
GetEnumerator() |
Returns an enumerator that can iterate the UIElementCollection. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
IndexOf(UIElement) |
Returns the index position of a specified element in a UIElementCollection. |
Insert(Int32, UIElement) |
Inserts an element into a UIElementCollection at the specified index position. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
Remove(UIElement) |
Removes the specified element from a UIElementCollection. |
RemoveAt(Int32) |
Removes the UIElement at the specified index. |
RemoveRange(Int32, Int32) |
Removes a range of elements from a UIElementCollection. |
SetLogicalParent(UIElement) |
Sets the logical parent of an element in a UIElementCollection. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Explicit Interface Implementations
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) |
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) |
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) |
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 |
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[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) |
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) |
Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Converts an IEnumerable to an IQueryable. |