Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.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# 在代码隐藏中将旋转变换动画添加到情节提要_C#_Wpf_Animation_Storyboard - Fatal编程技术网

C# 在代码隐藏中将旋转变换动画添加到情节提要

C# 在代码隐藏中将旋转变换动画添加到情节提要,c#,wpf,animation,storyboard,C#,Wpf,Animation,Storyboard,我在代码隐藏中定义了以下动画: DoubleAnimation dbAscending = new DoubleAnimation(0, 15, new Duration(TimeSpan.FromMilliseconds(300))); (myImage.RenderTransform as RotateTransform).BeginAnimation(RotateTransform.AngleProperty, dbAscending); 这工作正常,当启动时,它将myImage旋转15

我在代码隐藏中定义了以下动画:

DoubleAnimation dbAscending = new DoubleAnimation(0, 15, new Duration(TimeSpan.FromMilliseconds(300)));
(myImage.RenderTransform as RotateTransform).BeginAnimation(RotateTransform.AngleProperty, dbAscending);
这工作正常,当启动时,它将
myImage
旋转15度。现在我只需要创建新的
故事板
并将动画添加到其中,因为我需要使用它的
完成的
事件。我有一个小问题,我注意到我可以将动画添加到
故事板.Children
,但我没有定义要将此动画应用到的对象和属性


提前感谢您的帮助,到目前为止,我只在XAML中创建了情节提要…

您需要在动画上设置情节提要附加的属性,例如:

DoubleAnimation dbAscending = new DoubleAnimation(0, 15, new Duration(TimeSpan.FromMilliseconds(300)));
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(dbAscending);
Storyboard.SetTarget(dbAscending, myImage);
Storyboard.SetTargetProperty(dbAscending, new PropertyPath("RenderTransform.Angle"));
(未经测试;也可以直接针对变换并减少路径到角度)