Panel.Children 屬性

定義

取得此 UIElementCollection 之子項目的 Panel

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

屬性值

UIElementCollection

UIElementCollection。 預設為空的 UIElementCollection

範例

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

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

備註

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

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

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

適用於

產品 版本
.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

另請參閱