This documentation is archived and is not being maintained.

Popup Class

Represents a pop-up window that has content.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)

public class Popup : FrameworkElement, IAddChild

Content Model:  Popup has one content property: Child. A Popup can have a maximum of one child, which can be any UIElement.

The following illustration shows a Popup control that has a Button as its parent.

Popup illustration

You can position a popup by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffsetProperty properties. For more information, see Popup Placement Behavior. When Popup is displayed on the screen, it does not reposition itself if its parent is repositioned.

A Popup displays its content in its own window on the screen. A Popup control supports animation when the AllowsTransparency property is set to true and the application is running with full trust. An application that is running with full trust has complete access to system resources and is typically installed on the user's system. For more information, see Security (WPF).

For bitmap and opacity effects to appear on the content of a Popup, you must set the effects directly on the Popup content. The content of a Popup does not inherit effects that are set on the Popup control or on any other element that is in the parent window.

A Popup is sized to its content by default. When this occurs, applying a RenderTransform or bitmap effects may cause the Popup to be obscured. This occurs because the default size of the content does not provide enough area for the effects to display. If more space is required, you can define a margin around the Popup content to increase the area that is available to the control. For an example, see Animated Popup Sample.

The Parent property must be set on the Popup when used in a XAML browser application (XBAP).

To create a tooltip, use the ToolTip and ToolTipService classes. For more information, see ToolTip Overview.

The following example shows how to create a Popup control.

<Popup Name="myPopup">
  <TextBlock Name="myPopupText" 
    Popup Text
Popup codePopup = new Popup();
TextBlock popupText = new TextBlock();
popupText.Text = "Popup Text";
popupText.Background = Brushes.LightBlue;
popupText.Foreground = Brushes.Blue;
codePopup.Child = popupText;

More Code

How to: Animate a Popup This example shows two ways to animate a Popup control.
How to: Specify a Custom Popup Position This example shows how to specify a custom position for a Popup control when the Placement property is set to Custom.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0