Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Windows.Media.Animation.AnimationTimeline)和#x27;由于其保护级别,无法访问_C#_Wpf - Fatal编程技术网

C# System.Windows.Media.Animation.AnimationTimeline)和#x27;由于其保护级别,无法访问

C# System.Windows.Media.Animation.AnimationTimeline)和#x27;由于其保护级别,无法访问,c#,wpf,C#,Wpf,您好,我正试图以编程方式控制WPF动画,但出现上述错误,是否有人可以帮助解决此错误-不太熟悉c#-谢谢 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用System.Windows; 使用System.Windows.Controls; 使用System.Windows.Data; 使用System.Windows.Documents; 使用System.Windows.Input; 使用System.Windows.Media; 使

您好,我正试图以编程方式控制WPF动画,但出现上述错误,是否有人可以帮助解决此错误-不太熟悉c#-谢谢

使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用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的交互逻辑 ///


}

这意味着您无法使用“新建”创建“时钟”对象的实例。可以使用类似StartAnimation()方法的animation.CreateClock()方法来完成。不管怎样,对代码稍加修改就可以使其正常工作。希望下面的代码能给你一个想法:

using System;
using System.Windows.Media.Animation;
using System.Windows;
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Windows.Shapes;

namespace WpfApplication10 { /// /// Interaction logic for Window1.xaml ///

public partial class Window1: Window
{
    public Window1()
    {
        InitializeComponent();

        DoubleAnimation animate = new DoubleAnimation();
        animate.To = 300;
        animate.Duration = new Duration(TimeSpan.FromSeconds(5));
        animate.RepeatBehavior = RepeatBehavior.Forever;
        clock = animate.CreateClock();
    }

    AnimationClock clock;
    void StartAnimation()
    {        
        test.ApplyAnimationClock(Ellipse.WidthProperty, clock);
    }

    void PauseAnimation()
    {
        clock.Controller.Pause();
    }

    void ResumeAnimation()
    {
        clock.Controller.Resume();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        StartAnimation(); 
    }

   }
}
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(); 
    }

   }
using System;
using System.Windows.Media.Animation;
using System.Windows;
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Windows.Shapes;

namespace WpfApplication10 { /// /// Interaction logic for Window1.xaml ///

public partial class Window1: Window
{
    public Window1()
    {
        InitializeComponent();

        DoubleAnimation animate = new DoubleAnimation();
        animate.To = 300;
        animate.Duration = new Duration(TimeSpan.FromSeconds(5));
        animate.RepeatBehavior = RepeatBehavior.Forever;
        clock = animate.CreateClock();
    }

    AnimationClock clock;
    void StartAnimation()
    {        
        test.ApplyAnimationClock(Ellipse.WidthProperty, clock);
    }

    void PauseAnimation()
    {
        clock.Controller.Pause();
    }

    void ResumeAnimation()
    {
        clock.Controller.Resume();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        StartAnimation(); 
    }

   }
}