c# - WPF 弹出窗口 : open with animation

标签 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 框架 3.5 版。

最佳答案

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

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

关于c# - WPF 弹出窗口 : open with animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20069686/

相关文章:

c# - 在 C# 中拆分字符串

c# - 当前上下文中不存在名称 'form'

c# - Asp.net Web api 请求的资源不支持http方法 'GET'

c# - "Global"WPF ViewModel 属性

c# - 在没有窗口的 WPF 应用程序中处理命令

xaml - 如何更改 Windows Phone 7 中进度指示器的颜色

c# - 使用 LINQ 和匿名类型进行透视?

c# - WPF-mvvm。我怎样才能实现这样的 View (设计,图形用户界面)?

c# - 带有 DataTemplateSelector 和绑定(bind)内容的 ContentControl

c# - Wpf - 接收框架元素属性的属性值更改通知