Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[ContentPropertyAttribute("Child")] [LocalizabilityAttribute(LocalizationCategory.None)] public class Popup : FrameworkElement, IAddChild
/** @attribute ContentPropertyAttribute("Child") */ /** @attribute LocalizabilityAttribute(LocalizationCategory.None) */ public class Popup extends FrameworkElement implements IAddChild
ContentPropertyAttribute("Child") LocalizabilityAttribute(LocalizationCategory.None) public class Popup extends FrameworkElement implements IAddChild
To add a Child object to a Popup in Extensible Application Markup Language (XAML), nest the object in the Popup element tags. The following example shows how to create a Popup control by using Extensible Application Markup Language (XAML).
<Popup Name="myPopup"> <TextBlock Name="myPopupText" Background="LightBlue" Foreground="Blue"> Popup Text </TextBlock> </Popup>
To add content to a Popup in code, use the Child object. The following example shows how to create a Popup control by using code.
Popup codePopup = new Popup(); TextBlock popupText = new TextBlock(); popupText.Text = "Popup Text"; popupText.Background = Brushes.LightBlue; popupText.Foreground = Brushes.Blue; codePopup.Child = popupText;
The following illustration shows a Popup control that has a Button as its parent.
A Popup displays its content in its own window on the screen. When Popup is displayed on the screen, it does not reposition itself if its parent is repositioned.
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.
The Parent property must be set on the Popup when used in a XAML browser application (XBAP).
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.
This example shows how to create a Popup control. Use Popup controls to display brief information or menus in a separate window that floats above your application window relative to a designated element or screen coordinate.
The following example shows how to create a Popup that is the logical child of a Button control. A Button can have only one child; hence, the text for the Button and Popup controls is embedded in a StackPanel. The Popup content contains a TextBlock that displays content that is typed in a TextBox by the user in the Popup window when it is visible.
<Button HorizontalAlignment="Left" Click="DisplayPopup" Width="150" Margin="20,10,0,0"> <StackPanel> <TextBlock>Display Your Popup Text</TextBlock> <Popup Name="myPopup"> <TextBlock Name="myPopupText" Background="LightBlue" Foreground="Blue"> Popup Text </TextBlock> </Popup> </StackPanel> </Button>
For the complete sample, see Popup Sample.
|How to: Position a Popup|| |
This set of examples shows how to use the placement properties to specify the position of a Popup control.
|How to: Animate a Popup|| |
This example shows two ways to animate a Popup control.
|How to: Specify a Custom Popup Position|
|How to: Set the Placement Property for a Popup or Tooltip|| |
This example shows how the PlacementMode enumeration values help you position a Popup or a tooltip control. Use the PlacementMode enumeration values to set the Popup.Placement, ToolTip.Placement, and ToolTipService.Placement properties.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.