Я хочу сделать анимацию, где один объект будет перемещаться из одной ячейки сетки в другую. Я пытался вычислить положение объектов, но это не сработало (это дало мне неправильные значения). Вот код, если кому интересно:
Point locationToScreen = (((e.Source as Button).Content as Viewbox).Child as Label).PointToScreen(new Point(0, 0));
PresentationSource source = PresentationSource.FromVisual((((e.Source as Button).Content as Viewbox).Child as Label));
Point pt = source.CompositionTarget.TransformFromDevice.Transform(locationToScreen);
Point a = (letters.Children[_words[_index].Index] as TextBlock).PointToScreen(new Point(0, 0));
PresentationSource sos = PresentationSource.FromVisual((letters.Children[_words[_index].Index] as TextBlock));
Point pt2 = sos.CompositionTarget.TransformFromDevice.Transform(a);
TranslateTransform tt = new TranslateTransform();
(((e.Source as Button).Content as Viewbox).Child as Label).RenderTransform = tt;
DoubleAnimation da1 = new DoubleAnimation(0, -(pt.Y - pt2.Y)/2, new Duration(TimeSpan.FromSeconds(1)));
DoubleAnimation da2 = new DoubleAnimation(0, -(pt.X - pt2.X)/2, new Duration(TimeSpan.FromSeconds(1)));
tt.BeginAnimation(TranslateTransform.YProperty, da1);
tt.BeginAnimation(TranslateTransform.XProperty, da2);
Так как мне это сделать? Есть ли простой способ перемещения объекта из одного контейнера в другой?