Rate this:
See more:
After applying transaleTransform on ellipse , it's position not getting change. graphically it's position get change on canvas. But when getting it's position by below code it's postion remain same.

``` Point pt = new Point();
pt.X = (double)el.GetValue(Canvas.LeftProperty);
pt.Y = (double)el.GetValue(Canvas.TopProperty);```

code for translating it

``` TranslateTransform offsetTransform = new TranslateTransform();

DoubleAnimation offsetXAnimation = new DoubleAnimation(0,dx, new Duration(TimeSpan.FromSeconds(duration)));
DoubleAnimation offsetYAnimation = new DoubleAnimation(0,dy, new Duration(TimeSpan.FromSeconds(duration)));
//offsetXAnimation.RepeatBehavior = RepeatBehavior.Forever;
offsetXAnimation.BeginTime = TimeSpan.FromSeconds(delay);
offsetTransform.BeginAnimation(TranslateTransform.XProperty, offsetXAnimation);
offsetTransform.BeginAnimation(TranslateTransform.YProperty, offsetYAnimation);
ellipse.RenderTransform = offsetTransform;```
Posted 2-Jan-13 4:35am
Sergey Alexandrovich Kryukov at 2-Jan-13 17:30pm

Where do you think you do it? :-)
—SA
footballpardeep at 3-Jan-13 4:37am

Let me explain one more time , what i am doing. Suppose an ellipse is at 100,200 position. i am translating it to position 400,500 by double animation (code is pasted in question). graphically ellipse changes it postion to 400,500. But now, when i select this ellipse to get it's position (by using ellipse.getvalue(Canvas.leftproperty)) , it' showing me 100,200.

Rate this:

## Solution 1

I cannot set where do you update the properties related to the position of `Ellipse`.

I would agree that you do if I saw something like
```myCanvas.SetLeft(MyEllipse, displacementX);
myCanvas.SetTop(MyEllipse, displacementY);```

http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.settop.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.setleft.aspx[^].

Now about the animation. I cannot see where you animate the position of a `UIElement` of `Canvas`. You do it to the `TranslateTransform`, which is a right approach, but you should not expect that any dependency property of you `UIElement` are updated. These are just different things.

—SA
footballpardeep at 3-Jan-13 4:39am

what i am doing. Suppose an ellipse is at 100,200 position. i am translating it to position 400,500 by double animation (code is pasted in question). graphically ellipse changes it postion to 400,500. But now, when i select this ellipse to get it's position (by using ellipse.getvalue(Canvas.leftproperty)) , it' showing me 100,200.
Sergey Alexandrovich Kryukov at 3-Jan-13 11:31am

Right, because you do not animate this property; you animate the transform.
—SA
footballpardeep at 3-Jan-13 4:41am

i can change the postion of ellipse directly by ellipse.setValue(Canvas.leftProperty,point.X); ellipse.setvalue(Canvas.TopProperty.point.Y). But i want animating effect.
Sergey Alexandrovich Kryukov at 3-Jan-13 11:30am

Right. Do you have animated effect by TranslateTransform? If you do, what's wrong about it. If you do not, what's going on? You were not asking about animation itself; you were asking about the resulting value of that dependency property...
Keep in mind that you can always achieve fully custom animation using an extra thread and Dispatcher.
—SA