双动画或更新依赖项属性后,椭圆位置不会更改。 [英] Ellipse position not changing after double animation or Updating dependency property.
问题描述
在椭圆上应用transaleTransform后,它的位置没有变化。图形上它的位置在画布上得到改变。但是当通过下面的代码得到它的位置时,它的位置保持不变。
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;
推荐答案
我无法设置更新与<$位置相关的属性的位置c $ c> Ellipse 。
如果我看到类似
I cannot set where do you update the properties related to the position ofEllipse
.
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 [ ^ ]。
现在关于动画。我无法看到你在哪里设置 UIElement
Canvas
的位置。你可以使用 TranslateTransform
,这是一种正确的方法,但你不应该期望你的任何依赖属性 UIElement
已更新。这些只是不同的事情。
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.
这篇关于双动画或更新依赖项属性后,椭圆位置不会更改。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!