Panel.Children Właściwość

Definicja

UIElementCollection Pobiera element podrzędny tego Panelelementu .

public:
 property System::Windows::Controls::UIElementCollection ^ Children { System::Windows::Controls::UIElementCollection ^ get(); };
public System.Windows.Controls.UIElementCollection Children { get; }
member this.Children : System.Windows.Controls.UIElementCollection
Public ReadOnly Property Children As UIElementCollection

Wartość właściwości

Klasa UIElementCollection. Wartość domyślna to pusta UIElementCollectionwartość .

Przykłady

W poniższym przykładzie kodu pokazano, jak za pomocą Children właściwości dodać UIElement element podrzędny Panel do elementu.

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

Uwagi

Kolekcja ChildrenPanel elementu może składać się tylko z UIElement obiektów. UIElement Dodanie elementu podrzędnego Panel do niejawnie powoduje dodanie go do UIElementCollection elementu dla Panel elementu .

Nie używaj tej kolekcji z klasami pochodnymi Panel ; zamiast tego użyj InternalChildren kolekcji.

Ta właściwość zwraca wartość null , jeśli Panel właściwość jest powiązana z danymi.

Dotyczy

Zobacz też