开发者

how to show / hide WPF window by blur effect

I have a WPF window. I want to add blurring effect. I.e. When i say Show() or Close() it should blur into view and blur out of view.

I tried using Effect = new BlurEffect(), but i believe it is when windows is visible

Edit: I figured out that I could actually control the opa开发者_高级运维city, so I have decided to fade the window.


Following worked for me.

        var _sb = new Storyboard();
        var da = new DoubleAnimation(0.0, 1.0, new Duration(time)) {AutoReverse = false};
        Storyboard.SetTargetProperty(da, new PropertyPath(OpacityProperty));
        _sb.Children.Clear();
        _sb.Children.Add(da);
        this.Opacity = 0;
        Show();
        _sb.Begin(this);


To the best of my knowledge you cannot blur an entire window (Window being defined as the Chrome window element) you can blur any UI element within the window.

You can accomplish this by creating an animation within Blend. Add the blur effect and then create a storyboard. You can title it whatever (BlurIn). Then within the time line set the start and ending of your blur effect. Place this animation either in a resource dictionary or within the xaml page you are triggering the effect on.

You can then call this animation via code like

private void BeginAnimation()
        {
            stroyboard1.Begin();
        }

I don't know how you have your app set up but depending upon how you are using UI Elements, views you can have objects or views appear with this blur effect applied onLoad or on an event handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜