Live Chat Icon For mobile
Live Chat Icon

How can I animate a Popup ?

Platform: WPF| Category: Popup

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.

[XAML]

<Popup IsOpen='{Binding ElementName=myCheckBox,Path=IsChecked}' 
       PlacementTarget='{Binding ElementName=myCheckBox}'            
       AllowsTransparency='True'
       PopupAnimation='Slide'
       HorizontalOffset='50'
       VerticalOffset='50'
       >
  <!--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'
          Margin='150'>
    <Canvas.RenderTransform>
      <RotateTransform x:Name='theTransform' />
    </Canvas.RenderTransform>
    <TextBlock TextWrapping='Wrap' Foreground='White'>
      Rotating Popup
    </TextBlock>
  </Canvas>
</Popup>

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.