【问题标题】:weird issue when drawing a forth and back path in wpf在 wpf 中绘制来回路径时出现奇怪的问题
【发布时间】:2016-04-29 11:39:01
【问题描述】:

我在 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>

【问题讨论】:

    标签: c# wpf path pathgeometry


    【解决方案1】:

    StrokeMiterLimit 更改为Path(默认为10)

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

    【讨论】:

    • 或者只设置StrokeLineJoin="Round"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    • 2021-03-18
    • 2012-02-19
    • 1970-01-01
    相关资源
    最近更新 更多