单击按钮后,我会使按钮不可见。是否有任何漂亮的动画(可编程代码来自代码)代码可以消除按钮而不是突然消失?
答案 0 :(得分:4)
这应该对你有所帮助。只需致电FadeOut(myButton)
:
private void FadeOut(UIElement fe, int seconds = 2)
{
DoubleAnimation animation = new DoubleAnimation() { To = 0, Duration = new Duration(new TimeSpan(0, 0, seconds)) };
Storyboard sb = new Storyboard();
sb.Children.Add(animation);
Storyboard.SetTarget(animation, fe);
Storyboard.SetTargetProperty(animation, new PropertyPath(UIElement.OpacityProperty));
sb.Begin();
}