RenderTransformプロパティをアニメーション化する必要があるCanvasがあります。開始マトリックスと終了マトリックスは任意であるため、XAMLでストーリーボードを事前に作成することはできません。そのため、コードで作成しようとしています。これを行う方法の例は見つかりません。以下が私の最善の試みです。これは機能しません(コンパイルして実行しますが、rendertransformは変更されません)。
これをどのように行うべきかについての提案はありますか?
MatrixAnimationUsingKeyFrames anim = new MatrixAnimationUsingKeyFrames();
MatrixKeyFrameCollection keyframes = new MatrixKeyFrameCollection();
DiscreteMatrixKeyFrame start = new DiscreteMatrixKeyFrame(fromMatrix, KeyTime.FromPercent(0));
DiscreteMatrixKeyFrame end = new DiscreteMatrixKeyFrame(toMatrix, KeyTime.FromPercent(1));
keyframes.Add(start);
keyframes.Add(end);
anim.KeyFrames = keyframes;
Storyboard.SetTarget(anim, World.RenderTransform);
Storyboard.SetTargetProperty(anim, new PropertyPath("Matrix"));
Storyboard sb = new Storyboard();
sb.Children.Add(anim);
sb.Duration = TimeSpan.FromSeconds(4);
sb.Begin();