0
1つのオブジェクトが1つのグリッドセルから別のグリッドセルに移動するアニメーションを作りたいと思います。私はオブジェクトの位置を計算しようとしましたが、うまくいきませんでした。関心のある人なら、コードは次のとおりです。グリッドセルのアニメーション
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);
どうすればよいですか?オブジェクトをあるコンテナから別のコンテナに移動する簡単な方法はありますか?
はい、これは1つのオブジェクトに過ぎません。しかし、私は本当に "何らかの依存性プロパティにバインドする"と言ってどういうことを理解していないのですか?単純な例を教えてください。 –