【发布时间】:2014-02-23 08:37:25
【问题描述】:
我的窗口中有一个Button,我如何使用 C# 中的代码来设置动画,使其向左移动 100 像素,一旦我点击它。
private void myButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
DoubleAnimation _DoubleAnimation = new DoubleAnimation();
_DoubleAnimation.From = 0;
_DoubleAnimation.To = 100;
_DoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
myButton.BeginAnimation(Button.RenderTransformOriginProperty, _DoubleAnimation);
}
【问题讨论】: