如何让弹出窗口动画?

时间:2012-01-10 18:36:25

标签: c# wpf

这是我的代码(假设我们在页面上有一个启动弹出窗口的按钮):

    private void button1_Click(object sender, RoutedEventArgs e)
    {            
        Rectangle rect = new Rectangle();
        rect.Width = 50;
        rect.Height = 50;

        Popup mypop = new Popup();
        mypop.Child = rect; // just to put something inside the popup for now           
        mypop.PopupAnimation = PopupAnimation.Slide;
        mypop.StaysOpen = false;
        mypop.PlacementTarget = button1; // open next to the button
        mypop.IsOpen = true;
    }

弹出窗口只显示没有动画,即使我设置了PopupAnimation属性..有谁知道为什么?

1 个答案:

答案 0 :(得分:1)

请参阅:Popup class

  

当AllowTransparency属性设置为true且应用程序以完全信任方式运行时,Popup控件支持动画