Popup.CreateRootPopup(Popup, UIElement) 方法

定义

将子元素附加到 Popup 控件。Attaches a child element to a Popup control.

public:
 static void CreateRootPopup(System::Windows::Controls::Primitives::Popup ^ popup, System::Windows::UIElement ^ child);
public static void CreateRootPopup (System.Windows.Controls.Primitives.Popup popup, System.Windows.UIElement child);
static member CreateRootPopup : System.Windows.Controls.Primitives.Popup * System.Windows.UIElement -> unit

参数

popup
Popup

向其添加子内容的 PopupThe Popup to which to add child content.

child
UIElement

UIElement 子内容。The UIElement child content.

注解

您可能需要创建一个自定义控件, 该控件具有与现有控件相同的功能, 并且还展示的行为PopupYou might want to create a custom control that has the same functionality as an existing control and also exhibits the behavior of a Popup. 可以通过Popup Popup将添加到控件并调用CreateRootPopup方法来使控件的行为类似于。You can make your control behave like a Popup by adding a Popup to your control and calling the CreateRootPopup method.

此方法将child分配给子属性, 并将以下属性绑定child到。This method assigns child to the child property and binds the following properties to child.

你应在控件中将它们作为依赖项属性实现, 以便可以使用与相同的方式PopupYou should implement these as dependency properties in your control so it can be used the same way as a Popup. 有关详细信息,请参阅自定义依赖属性For more information, see Custom Dependency Properties.

当你调用CreateRootPopupchild , 不能UIElement是的子级。When you call CreateRootPopup, child cannot be a child of a UIElement. 此外, PlacementTarget在调用此方法之前, 应在控件上设置。Also, PlacementTarget should be set on your control before you call this method.

适用于