WPF Popup : open with animation

2019-06-16 04:07发布

I am using a wpf popup control.

<Popup x:Name="tabHolder" IsOpen="False" 
    PopupAnimation="Slide" Placement="Bottom" 
    PlacementTarget="{Binding ElementName=mainWidgetWindow}">
    <Grid Height="105" Width="315" />
</Popup>

Here I have set popup animation property to slide. But when it opens, it doesn't animate. Do I have to add any other configuration for popup to open with animation option slide?

I am using .net framework version 3.5.

2条回答
一纸荒年 Trace。
2楼-- · 2019-06-16 04:44

Popup will animate if you have set AllowsTransparency true. like -

AllowsTransparency="True".
查看更多
Animai°情兽
3楼-- · 2019-06-16 05:02

From MSDN

A Popup can only animate when the AllowsTransparency property is set to true. This requires the application that creates the Popup control to run with full trust. If the PlacementTarget is animated, the Popup will not be animated.

XAML should look like

<DockPanel  Width="500" Background="Aqua">
  <Popup Placement="Center" PlacementRectangle="0,0,30,50"  
          IsOpen ="True" AllowsTransparency="True"
          PopupAnimation="Fade">
    <TextBlock Background="Purple">Popup Text</TextBlock>
  </Popup>
</DockPanel>

And you can read more here.

查看更多
登录 后发表回答