I see a strange behaviour dragging in Line shape over a Canvas that I cannot explain. The Line shape is in a Thumb DataTemplate like so:
I had the same problem and after this answer "For a Line the correct value to animate the dragging of the ellipse on the canvas is the difference of the displacement between two consecutive DragDelta events." I developed this solution, worked for me, hope this helps someone
public class Connector : Thumb
{
private double _oldX = 0;
private double _oldY = 0;
public Connector()
{
DragDelta += Connector_DragDelta;
DragCompleted += Connector_DragCompleted;
}
private void Connector_DragCompleted(object sender, DragCompletedEventArgs e)
{
_oldX = 0;
_oldY = 0;
}
private void Connector_DragDelta(object sender, DragDeltaEventArgs e)
{
Thumb thumb = e.Source as Thumb;
DiagramConnectorViewModel viewModel = (DiagramConnectorViewModel)thumb.DataContext;
double leftOffSet = _oldX - e.HorizontalChange;
_oldX = e.HorizontalChange;
viewModel.X1 -= leftOffSet;
viewModel.X2 -= leftOffSet;
double topOffSet = _oldY - e.VerticalChange;
_oldY = e.VerticalChange;
viewModel.Y1 -= topOffSet;
viewModel.Y2 -= topOffSet;
}