語言

Popup.Child 屬性

定義

取得或設定控制內容 Popup 。

public:
 property System::Windows::UIElement ^ Child { System::Windows::UIElement ^ get(); void set(System::Windows::UIElement ^ value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.UIElement Child { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Child : System.Windows.UIElement with get, set
Public Property Child As UIElement

屬性值

控制 UIElement 內容 Popup 。 預設值為 null。

屬性

範例

以下範例說明如何將內容加入 Popup 控制項。

Popup myPopupWithText = new Popup();
TextBlock textBlock = new TextBlock();
textBlock.Text = "Popup Text";
textBlock.Background = Brushes.Yellow;
myPopupWithText.Child = textBlock;
myStackPanel.Children.Add(myPopup);
Dim myPopupWithText As New Popup()
Dim textBlock As New TextBlock()
textBlock.Text = "Popup Text"
textBlock.Background = Brushes.Yellow
myPopupWithText.Child = textBlock
myStackPanel.Children.Add(myPopup)
<DockPanel>
  <Popup IsOpen="True">
    <TextBlock Background="Yellow">Popup Text</TextBlock>
  </Popup>
</DockPanel>

備註

內容模型:該 Child 屬性是控制項唯一的內容屬性 Popup 。 A Popup 只能有一個 UIElement 子節點,但該子節點可以包含複雜的嵌入內容。 例如,子節點可以是 StackPanel 包含 Image、 文字及其他控制項的 a。

當內容被加入 Popup 控制項時,該 Popup 控制項成為該內容的邏輯父體。 同樣地,內容 Popup 被視為 的邏輯子節點 Popup。 子內容不會被加入包含控制 Popup 項的視覺樹中。 相反地,當 設定 IsOpen 為 true時,子內容會以獨立的視覺樹狀視窗呈現。

相依財產資訊

Item 價值觀
識別碼欄位 ChildProperty
元資料屬性設為 true None

適用於