The margin of the shape in the canvas is a negative value. You must specify the alignment of the shape.
Define XAML as follows,
<Canvas>
<Path X: Name = "pathlink" stroke = "black" strokethickness = "1"> </path>
<! -- <Path X: Name = "pathstart" fill = "red"> </path> -->
<Ellipse X: Name = "pathstart" fill = "red" width = "7" Height = "7" horizontalalignment = "Left" verticalignment = "TOP"> </ellipse>
<Path X: Name = "pathend"> </path>
<Line X: Name = "testline" stroke = "blue"> </line>
</Canvas>
If the pathstart alignment mode is not specified, the path is aligned in the upper left corner during design, but the center alignment is changed during running, leading to incorrect pathstart positioning. When the value of margin. Left or margin. Right is negative, pathstart locates at the position of margin. Left/2, and the coordinate of the line specified by the dash (Blue Line) is located correctly. For example:
If margin. Left or margin. Right is a positive value, the location is correct. If the center is located here, pathstart should be located at the position of margin. Left * 2, but this is actually not the case.