当使用DoubleAnimation进行动画处理时,WPF控件会消失

时间:2016-01-21 07:25:04

标签: c# wpf xaml animation doubleanimation

我有一个TextBox(toAnimate)和一个Button(toClick)。 当我单击按钮时,TextBox消失。 但它应该在X Position 20单位上移动。

我做错了什么?

//double left = Canvas.GetLeft(toAnimate); Returned wrong value.
TranslateTransform tanl = new TranslateTransform();
Vector pos = VisualTreeHelper.GetOffset(toAnimate);
double left = pos.X;
toAnimate.RenderTransform = tanl;
DoubleAnimation doua = new DoubleAnimation((left + 20), left, TimeSpan.FromSeconds(3));
tanl.BeginAnimation(TranslateTransform.XProperty, doua);

0 个答案:

没有答案