Panel.Children Propiedad

Definición

Obtiene un UIElementCollection de elementos secundarios de este Panel.

C#
public System.Windows.Controls.UIElementCollection Children { get; }

Valor de propiedad

UIElementCollection

Objeto UIElementCollection. El valor predeterminado es un UIElementCollection vacío

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la Children propiedad para agregar un UIElement elemento secundario a un Panel elemento .

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

Comentarios

La Children colección de un Panel elemento solo puede constar de UIElement objetos . Al agregar un UIElement elemento secundario a un Panel elemento , se agrega implícitamente al UIElementCollection elemento para el Panel elemento .

No use esta colección con clases derivadas Panel ; use la InternalChildren colección en su lugar.

Esta propiedad devuelve null si está enlazado a Panel datos.

Se aplica a

Producto Versiones
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Consulte también