以下是將 EllipseObject 由 OriginalCanvas 轉換到 TargetCanvas,並保持不動的程式碼。
Point PointOfOriginal = new Point(Canvas.GetLeft(EllipseObject), Canvas.GetTop(EllipseObject)); GeneralTransform generalTransform = OriginalCanvas.TransformToVisual(TargetCanvas); OriginalCanvas.Children.Remove(EllipseObject); Point PointOfTarget = generalTransform.Transform(PointOfOriginal); Canvas.SetLeft(EllipseObject, PointOfTarget.X); Canvas.SetTop(EllipseObject, PointOfTarget.Y); TargetCanvas.Children.Add(EllipseObject);
沒有留言:
張貼留言