Popup.Child 属性

定义

获取或设置 Popup 控件的内容。Gets or sets the content of the Popup control.

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; }
member this.Child : System.Windows.UIElement with get, set
Public Property Child As UIElement

属性值

Popup 控件的 UIElement 内容。The UIElement content of the Popup control. 默认值为 nullThe default is null.

属性

示例

下面的示例演示如何将内容添加到Popup控件。The following example shows how to add content to a Popup control.

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>

注解

内容模型:属性是Popup控件的唯一内容属性。 ChildContent Model: The Child property is the only content property for the Popup control. 只能有一个UIElement作为子级, 但该子元素可以包含复杂的嵌入内容。 PopupA Popup can only have one UIElement as a child, but that child can contain complex embedded content. 例如, 子元素可以是StackPanel Image包含、文本和其他类型的控件的。For example, the child can be a StackPanel that contains an Image, text, and other types of controls.

Popup控件添加内容时Popup , 控件将成为内容的逻辑父级。When content is added to a Popup control, the Popup control becomes the logical parent to the content. 同样, Popup内容被视为的逻辑子级PopupSimilarly, the Popup content is considered to be the logical child of the Popup. 子内容不会添加到包含Popup控件的可视化树中。The child content is not added to the visual tree that contains the Popup control. 相反, 当设置为IsOpen true时, 子内容将呈现在单独的窗口中, 并具有其自己的可视化树。Instead, the child content is rendered in a separate window with its own visual tree when the IsOpen is set to true.

依赖项属性信息Dependency Property Information

标识符字段Identifier field ChildProperty
元数据属性设置为trueMetadata properties set to true NoneNone

适用于