Reputation: 220
I have a drawn polygon in WPF/XAML like this:
<Polygon
HorizontalAlignment="Right"
VerticalAlignment="Top" Margin="0,0,0,0"
Width="20"
Height="50"
Points="0 2,0,0 2,1"
Fill="Transparent"
Stretch="Fill" Stroke="#FFFFFF" StrokeThickness="1" />
This puts a white border on all three sides of the triangle. However, I only want a white border on two of the sides (not the left, flat side). On the third side, I want no border at all (this would look like an open triangle... kind of like a greater than sign >). Is there a way to do this? I have played around with the stroke thickness with no luck (doesn't let you specify per side).
Upvotes: 4
Views: 4843
Reputation: 128013
In order to create a filled shape with partially stroked edges, use a PathGeometry like this:
<Path StrokeThickness="1" Stroke="White" Fill="Transparent">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,0">
<PolyLineSegment Points="10,10 0,20"/>
<LineSegment Point="0,0" IsStroked="False"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
Upvotes: 3
Reputation: 3960
One way would be to use a Path rather than a polygon. Something like:
<Path Stroke="White">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="10,10" EndPoint="30,35"></LineGeometry>
<LineGeometry StartPoint="30,35" EndPoint="10,55"></LineGeometry>
</GeometryGroup>
</Path.Data>
</Path>
You may have to tweak the endpoints a bit, but it should get you fairly close to what you're after.
Upvotes: 3