我正在尝试遵循 Windows 应用商店应用程序中的图像路径。我希望图像遵循该路径并在遵循该路径时旋转。想象一下在平面上做曲线或类似的事情 this .
在 silverlight/wpf 的教程中,我发现了一些 Windows 应用商店应用程序中没有的东西,例如:DoubleAnimationUsingPath或MatrixAnimationUsingPath甚至PathListBox 。
我也尝试过在Blend中做那个动画(虽然我在windows世界的经验很少,但在blend中的体验更糟糕)但我什至做不到Path -> Make Layout Path .
我怎样才能做类似 unicycle animation 的事情在 Windows Metro 应用程序中?
编辑
我想使用路径,因为我想随机生成这些路径。手动混合关键帧适用于特定的受控路径。然而,随机生成这些关键帧似乎需要更多工作,而只是生成可遵循的随机弧路径。
最佳答案
我最终移植了 Petzold 解决方案(隐士戴夫给出的解决方案,我试图避免)。
但是,我必须做一些改变。
我将“xFormUnicycleMan”MatrixTransform
作为 MatrixAnimationUsingPath
的依赖属性传递给:
TargetElement="{Binding ElementName=xformUnicycleMan}"
然后,在 OnCompositionTargetRendering
中,我得到了它,并使用以下内容修改了需要采用的值:
MatrixTransform matrixTransform = this.TargetElement as MatrixTransform;
PropertyPath targetProperty = new PropertyPath("MatrixProperty");
PropertyInfo fieldInfo =
matrixTransform.GetType().GetRuntimeProperty(targetProperty.Path);
DependencyProperty dependencyProp =
fieldInfo.GetValue(matrixTransform) as DependencyProperty;
感谢@Miek 提供的帮助。
如果有人有更好的解决方案,我将不胜感激。
关于animation - 使用图像沿着弯曲路径行走,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15022867/