如何为任何控件设置 BlurEffect 动画?
我想要一个可重用的函数,它只需对任何特定的有效控件类型执行 BlurEffect 即可。
例如,
var animation = new DoubleAnimation
{
From = 0,
To = 8,
Duration = new TimeSpan(0, 0, 0, 2),
AutoReverse = true
};
control.Effect = new BlurEffect();
// How to cycle the From and To on the Blur Radius?
我不确定如何在代码隐藏中动态创建动画以使其成为可能。
I would like a reusable function that simply does a BlurEffect on any particular valid Control type.
e.g.
var animation = new DoubleAnimation
{
From = 0,
To = 8,
Duration = new TimeSpan(0, 0, 0, 2),
AutoReverse = true
};
control.Effect = new BlurEffect();
// How to cycle the From and To on the Blur Radius?
I am uncertain how to dynamically create an animation in code behind to make this possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
本文展示了如何在代码中定义动画和故事板。
您需要添加 BlurEffect 并使用 RadiusProperty 的blureffect 而不是RotateTransform.AngleProperty,如下所示:
-编辑-
我现在看到您正在使用Silverlight,而不是wpf(其中效果实现 IAnimatable)
我会尝试找到 silverlight 的解决方案
-edit2-
你见过/尝试过 这个? Msdn 还有一个 示例for silverlight
-edit3-
你的指导让我找到了正确的答案,如下所示:
应该注意的是,Silverlight 并不像 WPF 那样简单地制作动画,但最终这是可以做到的。
This article shows how to define an animation and story board in code.
You'd need to add the BlurEffect and use RadiusProperty of blureffect instead of RotateTransform.AngleProperty like this:
-edit-
I see now that you're using Silverlight, not wpf (where Effect implements IAnimatable)
i'll try and find a solution for silverlight
-edit2-
Have you seen/tried this? Msdn also has a sample for silverlight
-edit3-
Your direction got me towards the right answer which is as follows:
It should be noted that Silverlight does not make animations as easy as WPF, but in the end this can be done.