简体   繁体   中英

LineSegment.IsStroked missing in UWP

In Wpf you can

<Path Stroke="White" Fill="#50ffffff" StrokeThickness="2">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="20,20">
                    <LineSegment Point="100,20" />
                    <LineSegment Point="100, 100" IsStroked="False"/>
                    <LineSegment Point="20, 100"/>
                    <LineSegment Point="20, 20"/>
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>

To get

在此输入图像描述

Sadly in UWP there is no IsStroked property in the LineSegment class, is there any know workaround for this case?

Thanks

To overcome this limitation, you should be able to break down the Path into multiple Paths , skipping the areas without stroke. In the sample code, you could even keep it as a single Path by starting in the upper right corner and continuing counter-clockwise, ending in the lower right corner.

In more complex scenarios, having multiple Paths is a bit less clean than in WPF, but it should be a functional solution.

As long as there is only one gap, this should work too:

<Path Stroke="White" Fill="#50ffffff" StrokeThickness="2">
    <Path.Data>
        <PathGeometry>
            <PathFigure StartPoint="100,20" IsClosed="False">
                <LineSegment Point="20,20"/>
                <LineSegment Point="20,100"/>
                <LineSegment Point="100,100"/>
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM