私は3つのキャンバスを使用しています。一つは子供のキャンバス(1静的および回転します1)として、他の二つを持っている主なキャンバスです:このサンプルアプリでWPF TranslateTransformからキャンバス内のオブジェクトを別のキャンバス内の固定オブジェクトに変換
、私はStaticEl上の位置にRotatingElを移動します:
私は移動するボタンをクリックすると、予想通り、それは動作します:
が、それは間違っているに移動:0
は今、私はRotatingCanvasを回転させ、まだStaticElの場所にRotatingElの動きを持って、まだStaticElの角度に一致するように回転を調整したいです場所:
ここでは、移動ボタンをクリックして上の私のコードです:
GeneralTransform generalTransformStaticEl = StaticEl.TransformToVisual(MainCanvas);
Point pointstatic = generalTransformStaticEl.Transform(new Point());
GeneralTransform generalTransformRotEl = RotatingEl.TransformToVisual(MainCanvas);
Point pointrot = generalTransformRotEl.Transform(new Point());
double distancecalcX = pointstatic.X - pointrot.X;
double distancecalcY = pointstatic.Y - pointrot.Y;
DoubleAnimation ELMoveY = new DoubleAnimation();
ELMoveY.From = Canvas.GetTop(RotatingEl);
ELMoveY.To = Canvas.GetTop(RotatingEl)+(distancecalcY);
ELMoveY.Duration = new Duration(TimeSpan.FromSeconds(1.0));
DoubleAnimation ELMoveX = new DoubleAnimation();
ELMoveX.From = Canvas.GetLeft(RotatingEl);
ELMoveX.To = Canvas.GetLeft(RotatingEl)+(distancecalcX);
ELMoveX.Duration = new Duration(TimeSpan.FromSeconds(1.0));
RotatingEl.BeginAnimation(Canvas.LeftProperty, ELMoveX);
RotatingEl.BeginAnimation(Canvas.TopProperty, ELMoveY);
どのようにしてアニメーションの「To」を調整しても、回転キャンバスのRotatingElを静的StaticElの位置に移動し、RotatingElの回転をStaticElの向きに合わせて調整できますか?