I have a map represented by a Canvas.
This map is showing some Cities which have their Top and Left properties stored in an City.Y and a City.X properties
Now I'm trying to move an object from a city to another one. I have this method :
private void UpdateUI(City target)
{
var top = Canvas.GetTop(Representation);
var left = Canvas.GetLeft(Representation);
Debug.WriteLine("top : " + Canvas.GetTop(Representation) + ", left : " + Canvas.GetLeft(Representation));
int velocity = 2000;
TranslateTransform trans = new TranslateTransform();
Representation.RenderTransform = trans;
DoubleAnimation animY = new DoubleAnimation(0, target.Y - top, TimeSpan.FromMilliseconds(velocity));
DoubleAnimation animX = new DoubleAnimation(0, target.X - left, TimeSpan.FromMilliseconds(velocity));
animY.Completed += (o, e) => Debug.WriteLine("top : " + Canvas.GetTop(Representation) + ", left : " + Canvas.GetLeft(Representation));
trans.BeginAnimation(TranslateTransform.YProperty, animY);
trans.BeginAnimation(TranslateTransform.XProperty, animX);
}
- The Representation var is an Ellipse representating the actual object I want to move to the City "target"
- The first Debug.WriteLine is showing the original position of the Ellipse. The second one, called by the completion of the animY DoubleAnimation is, IMHO, trying to show the new position of the Ellipse, after the animation.
My problem is even if my Ellipse is moving on the Canvas (I see it moving in the representation of the Canvas), the two Debug.WriteLine are showing the exact same values, the original ones but not the new Left and Top properties it should has after the animation.
How can I update this property or get the actual position of the Ellipse instead of the original one ?