Partager via


How to: Create a Popup

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.

Example

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">
      <Border BorderBrush="Beige" BorderThickness="1">
       <TextBlock Name="myPopupText" Width="150" Background="LightBlue" 
         Foreground="Blue" TextWrapping="Wrap" />
      </Border>
    </Popup>
  </StackPanel>
</Button>

For the complete sample, see Popup Sample.

See Also

Reference

Popup

Concepts

Popup Overview

Other Resources

Popup Samples
Popup How-to Topics