Popup Class
This page is specific to:.NET Framework Version:3.03.5Silverlight 34.0
.NET Framework Class Library
Popup Class

Represents a pop-up window that has content.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

'Usage

Dim instance As Popup

'Declaration

<ContentPropertyAttribute("Child")> _
<LocalizabilityAttribute(LocalizationCategory.None)> _
Public Class Popup _
    Inherits FrameworkElement _
    Implements IAddChild
<Popup>
  Child
</Popup>
Remarks

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.

Examples

The following example shows how to create a Popup control.

<Popup Name="myPopup">
  <TextBlock Name="myPopupText" 
             Background="LightBlue" 
             Foreground="Blue">
    Popup Text
  </TextBlock>
</Popup>
Dim codePopup As Popup = New Popup()
Dim popupText As TextBlock = 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.
Inheritance Hierarchy

System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Media..::.Visual
        System.Windows..::.UIElement
          System.Windows..::.FrameworkElement
            System.Windows.Controls.Primitives..::.Popup
Thread Safety

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

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View