Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Panel.Children Property

Gets a UIElementCollection of child elements of this Panel.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public UIElementCollection Children { get; }
/** @property */
public UIElementCollection get_Children ()

public function get Children () : UIElementCollection

<object>
  <UIElementCollection .../>
</object>

Property Value

A UIElementCollection. The default value is an empty UIElementCollection.

Content Model: Panel enforces a strong content model for child content. The Children collection of a Panel element can only consist of UIElement objects. Adding a UIElement child to a Panel implicitly adds it to the UIElementCollection for the Panel element.

Do not use this collection with derived Panel classes; use the InternalChildren collection instead.

This property returns a null reference (Nothing in Visual Basic) if the Panel is data bound.

The following code example demonstrates how to use the Children property to add a UIElement child to a Panel element.

StackPanel myStackPanel = new StackPanel();
Button myButton = new Button();
myButton.Content = "Press me";
myStackPanel.Children.Add(myButton);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2014 Microsoft