在 wpf 中绘制来回路径时出现奇怪的问题

weird issue when drawing a forth and back path in wpf

我在 C# 代码中使用 Path 绘制了一系列点。我只是在xaml中举了一个例子。

所以折线是从 (20,37) 到 (20,36) 和 returns 到 (20,37)。应该很短吧?但它变成了一个大约 9dp 长的段。

如果我简单地从 (20,37) 绘制到 (20,36),它表现正常。因为点是实时绘制的,所以我不能做预处理。

为什么会这样,如何解决?

<Path Stroke="Black" StrokeThickness="2">
    <Path.Data>
        <PathGeometry>
            <PathFigure StartPoint="20,37">
                <PathFigure.Segments>
                    <LineSegment Point="20,36"/>
                    <LineSegment Point="20,37"/>
                </PathFigure.Segments>
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>

StrokeMiterLimit 更改为 Path(默认为 10)

<Path Stroke="Black" StrokeThickness="2" StrokeMiterLimit="1">