Point curPoint = new Point();
curPoint.X = Canvas.GetLeft(ell);
curPoint.Y = Canvas.GetTop(ell);
double _s = System.Math.Sqrt(Math.Pow((deskPoint.X - curPoint.X), 2) + Math.Pow((deskPoint.Y - curPoint.Y), 2));
double _secNumber = (_s / 1000) * 500;
Storyboard storyboard = new Storyboard();
//创建X轴方向动画
DoubleAnimation doubleAnimation = new DoubleAnimation(
Canvas.GetLeft(ell),
deskPoint.X,
new Duration(TimeSpan.FromMilliseconds(_secNumber))
);
Storyboard.SetTarget(doubleAnimation, ell);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)"));
storyboard.Children.Add(doubleAnimation);
//创建Y轴方向动画
doubleAnimation = new DoubleAnimation(
Canvas.GetTop(ell),
deskPoint.Y,
new Duration(TimeSpan.FromMilliseconds(_secNumber))
);
Storyboard.SetTarget(doubleAnimation, ell);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
storyboard.Children.Add(doubleAnimation);
//动画播放
storyboard.Begin();