您好我正在嘗試以編程方式控制WPF動畫,但獲取上述錯誤,有人可以幫助錯誤 - 不是很熟悉c# - 謝謝System.Windows.Media.Animation.AnimationTimeline)'由於其保護級別而無法訪問
using System;
using System.Collections.Generic;使用System.Linq的 ; using System.Text;使用System.Windows的 ; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using 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();
}
}
}