【发布时间】:2011-04-02 02:38:10
【问题描述】:
您好,我正在尝试以编程方式控制 WPF 动画,但出现上述错误,有人可以帮助解决该错误 - 对 c# 不太熟悉 - 谢谢
using System;
使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Text; 使用 System.Windows; 使用 System.Windows.Controls; 使用 System.Windows.Data; 使用 System.Windows.Documents; 使用 System.Windows.Input; 使用 System.Windows.Media; 使用 System.Windows.Media.Imaging; 使用 System.Windows.Navigation; 使用 System.Windows.Shapes; 使用 System.Windows.Media.Animation;
命名空间 WpfApplication10 { /// /// Window1.xaml 的交互逻辑 ///
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
AnimationClock clock;
void StartAnimation()
{
DoubleAnimation animate = new DoubleAnimation();
animate.To = 300;
animate.Duration = new Duration(TimeSpan.FromSeconds(5));
animate.RepeatBehavior = RepeatBehavior.Forever;
clock = animate.CreateClock();
test.ApplyAnimationClock(Ellipse.WidthProperty, clock);
}
void PauseAnimation()
{
clock = new AnimationClock();
clock.Controller.Pause();
}
void ResumeAnimation()
{
clock.Controller.Resume();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
PauseAnimation();
}
}
}
【问题讨论】: