Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPFC#4.0
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
Comments
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.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

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);
 
Please see:
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
  Permalink  
Comments
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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 840
1 OriginalGriff 437
2 Abhinav S 303
3 thatraja 215
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,122
1 OriginalGriff 4,520
2 Peter Leow 3,744
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid