我正在研究包含信息的平面,方形瓷砖的3D轮播。当人们按下下一个按钮和上一个按钮时,我正在将这个轮播动画设置为旋转。从代码中使用Storyboard时的WPF动画问题
我已经通过在RotateTransform3D的Rotation属性上使用BeginAnimation将它应用于旋转木马,但似乎无法制作同一动画作品的Storyboard版本。我需要Storyboard版本的原因是HandOffBehavior.Compose参数,因为没有它,多次单击我的下一个和上一个按钮会导致旋转木马未对齐。
这里是故事板代码:
RotateTransform3D tempTransform = (RotateTransform3D)wheel.Transform;
AxisAngleRotation3D rotation = (AxisAngleRotation3D)tempTransform.Rotation;
Storyboard storyboard = new Storyboard();
DoubleAnimation animation = new DoubleAnimation();
animation.By = defaultAngle;
animation.Duration = TimeSpan.FromSeconds(.5);
Storyboard.SetTarget(animation, rotation);
Storyboard.SetTargetProperty(animation, new PropertyPath("Angle"));
storyboard.Children.Add(animation);
storyboard.Duration = animation.Duration;
storyboard.Begin(new FrameworkContentElement(), HandoffBehavior.Compose);
出于某种原因,该代码会导致绝对没有。我跟着我写给这封信的例子,所以我很沮丧。任何帮助是极大的赞赏。如果我可以复制HandOffBehavior.Compose,我也完全开放使用BeginAnimation。