bto.rdz bto.rdz - 1 month ago 8
C# Question

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

enter image description here

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

Thanks

Answer

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.