This documentation is archived and is not being maintained.

How to: Animate a Popup

This example shows two ways to animate a Popup control.

The following example sets the PopupAnimation property to a value of Slide, which causes the Popup to "slide-in" when it appears.

In order to rotate the Popup, this example assigns a RotateTransform to the RenderTransform property on the Canvas, which is the child element of the Popup.

For the transform to work correctly, the example must set the AllowsTransparency property to true. In addition, the Margin on the Canvas content must specify enough space for the Popup to rotate.

<Popup IsOpen="{Binding ElementName=myCheckBox,Path=IsChecked}" 
       PlacementTarget="{Binding ElementName=myCheckBox}"            
  <!--The Margin set on the Canvas provides the additional 
      area around the Popup so that the Popup is visible when 
      it rotates.-->
  <Canvas Width="100" Height="100" Background="DarkBlue"
      <RotateTransform x:Name="theTransform" />
    <TextBlock TextWrapping="Wrap" Foreground="White">
      Rotating Popup

The following example shows how a Click event, which occurs when a Button is clicked, triggers the Storyboard that starts the animation.

<Button HorizontalAlignment="Left" Width="200" Margin="20,10,0,0">
    <EventTrigger RoutedEvent="Button.Click">
            From="0" To="360" Duration="0:0:5" AutoReverse="True"/>
  Click to see the Popup animate