2
一旦点击按钮,我会使按钮不可见。是否有任何漂亮的动画(可编程的代码背后的代码)使按钮消失而不是突然消失?silverlight:淡出按钮?
一旦点击按钮,我会使按钮不可见。是否有任何漂亮的动画(可编程的代码背后的代码)使按钮消失而不是突然消失?silverlight:淡出按钮?
这应该对你有帮助。只需致电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();
}
对于传送带和大括号,最好在动画完成后将可见性设置为折叠。 – AnthonyWJones 2010-06-03 09:41:23
好主意。但有时使用基于网格的布局,取决于按钮的位置,如果按钮突然折叠,可能会使窗体变得不可思议。无论如何,我绝对不会在这种情况下使用代码隐藏/编程路线...... XAML使事情变得简单。 – lo5 2010-06-03 09:58:22