Вы должны использовать DependencyProperty
для анимации
public class DragAdorner
{
public Point Position
{
get { return (Point)GetValue(PositionProperty); }
set { SetValue(PositionProperty, value); }
}
// Using a DependencyProperty as the backing store for PositionProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PositionProperty =
DependencyProperty.Register("Position", typeof(Point), typeof(DragAdorner), new UIPropertyMetadata(PositionChanged));
private static void PositionChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
UpdatePosition(Position);
}
}
Тогда вы можете сделать что-то вроде этого (не проверено)
double xPosLocation = (int)(dividerDistanceXAxis * virtualPosition) + YAxisData.SpacingLeft;
double yPosLocation = CalculateValueToYPosition(VirtualPriceOfVehicle);
Point newLocation = new Point(xPosLocation, yPosLocation);
PointAnimation myPointAnimation = new PointAnimation();
myPointAnimation.From = DragAdorner.Position;
myPointAnimation.To = newLocation;
myPointAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
Storyboard myStoryboard = new Storyboard();
myStoryboard.Children.Add(myPointAnimation);
Storyboard.SetTargetName(myPointAnimation, DragAdorner.Position);
myStoryboard.Begin();