Panel.Children 屬性

定義

取得此 UIElementCollection 之子項目的 Panel

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

屬性值

UIElementCollection

UIElementCollection。 預設為空的 UIElementCollection

範例

下列程式碼範例示範如何使用 Children 屬性將子系加入 UIElement 專案 Panel

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)

備註

專案的 Children 集合 Panel 只能包含 UIElement 物件。 UIElement將子系加入至 Panel ,以隱含方式將它加入至 UIElementCollection 專案的 Panel

請勿將此集合與衍生 Panel 類別搭配使用;請改用 InternalChildren 集合。

如果 系結資料, Panel 這個屬性會傳 null 回 。

適用於

另請參閱