在wpf中绘制前后路径时出现奇怪的问题

时间:2016-04-29 11:39:01

标签: c# wpf path pathgeometry

我在c#代码中用Path绘制了一系列点。我只是举例说明xaml。

因此折线从(20,37)到(20,36)并返回到(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>

1 个答案:

答案 0 :(得分:1)

更改Path的{​​{3}}(默认为10)

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