WPF 弹出窗口:用动画打开 [英] WPF Popup : open with animation

查看:27
本文介绍了WPF 弹出窗口:用动画打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 wpf 弹出控件.

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?

我使用的是 .net 框架 3.5 版.

I am using .net framework version 3.5.

推荐答案

来自 MSDN

仅当 AllowsTransparency 属性设置为 true 时,弹出窗口才能动画.这要求创建 Popup 控件的应用程序以完全信任的方式运行.如果 PlacementTarget 已设置动画,则不会为 Popup 设置动画.

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 应该看起来像

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>

您可以阅读更多这里.

这篇关于WPF 弹出窗口:用动画打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆