开发者

How can I set different stroke properties to in a path object in WPF

I have a path shape that I would like to combine lines that have different line thicknesses? The StrokeThickness property is set on the Path object so I cannot change it for different lines. This same issue would arise if I wanted to change my line color.

The reason I want to do this is so that I can draw an arrowhead. Charles Petzold arrowheads http://www.charlespetzold.com/blog/2007/04/191200.html don't work for me. If my line is dashed the closed arrowhead draws weirdly.

I figured a way to do it was to combine at the end of my path/line a new short line geometry that was thicker than the my original path/line and had TriangleLineCap, voila, got myself an arrowhead. But I can't combine geometries that have different line thicknesses and dashed types, etc.

Any ideas? 开发者_开发问答


Just use multiple Path objects in a panel like a Canvas or a Grid where they will draw on top of each other:

<Grid>
    <Path Stroke="Blue" StrokeThickness="2">
        <Path.Data>
            <EllipseGeometry Center="20 20" RadiusX="10" RadiusY="10" />
        </Path.Data>
    </Path>
    <Path Stroke="Green" StrokeThickness="1" StrokeDashArray="1 2">
        <Path.Data>
            <LineGeometry StartPoint="10 20" EndPoint="30 20"/>
        </Path.Data>
    </Path>
</Grid>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜