WPF Popup:用动画打开

时间:2013-11-19 11:00:06

标签: c# wpf xaml wpf-controls

我正在使用wpf弹出控件。

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

这里我设置了要弹出的弹出动画属性。但是当它打开时,它没有动画。我是否必须添加任何其他弹出窗口配置才能打开动画选项幻灯片?

我正在使用.net framework 3.5版。

2 个答案:

答案 0 :(得分:21)

来自MSDN

  

当AllowTransparency属性设置为true时,Popup只能进行动画处理。这需要创建Popup控件的应用程序以完全信任的方式运行。   如果PlacementTarget是动画的,则弹出窗口不会被设置动画。

XAML应该看起来像

<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>

您可以阅读更多here

答案 1 :(得分:6)

如果您将allowsTransparency设置为true,则弹出将动画显示。 喜欢 -

AllowsTransparency="True".