Draw solid color triangle using XAML only
67,859
Solution 1
<Polygon Points="0,0 80,50, 0,100" Stroke="Black" Fill="Black" />
Solution 2
I want to add these to their collection:
<Polygon Points="5,0 10,10, 0,10" Stroke="Black" Fill="Black" />
<Polygon Points="0,0 5,10, 10,0" Stroke="Black" Fill="Black" />
Solution 3
Using paths
<Path Width="33" Height="37" Stretch="Fill" Stroke="Black" Fill="Black" Data="F1 M 319.344,237.333L 287.328,218.849L 287.328,255.818L 319.344,237.333 Z "/>
<Path Width="33" Height="37" Stretch="Fill" Stroke="Black" Fill="Black" Data="F1 M 287.328,237.333L 319.344,255.818L 319.344,218.849L 287.328,237.333 Z "/>
Related videos on Youtube
Author by
sll
Updated on September 21, 2020Comments
-
sll over 3 years
Is it possible to draw a filled in triangle using XAML only (not a code behind solution)?
Triangle should be like on the image below to represent sort direction
Ascending/Descending
along with a sort button on a chart control:EDIT: The solution, thanks to SpeziFish:
Ascending:
<Polygon Points="0,0 8,5, 0,10" Stroke="Black" Fill="Black" />
Descending:
<Polygon Points="8,0 0,5, 8,10" Stroke="Black" Fill="Black" />
-
erikH over 12 yearsDrawing a triangle with an rectangle? You could look into
Path
instead. Look here for a basic example. -
sll over 12 years@erikH : sorry, the main requirement is a XAML only
-
-
sll over 12 yearssorry, the main requirement is a XAML only so Polygon is fine. How to make it smaller 10 times?
-
SpeziFish over 12 yearsDevide the numbers by ten. The numbers are easily the pixel coordinates (x,y) of the corners.
-
John Demetriou over 7 yearshow do you position and rotate though? I mean I want to draw a triangle that will be position around a circle (outside that circle) based on binding. Any ideas?
-
John Demetriou over 7 yearshow do you position and rotate though? I mean I want to draw a triangle that will be position around a circle (outside that circle) based on binding. Any ideas?
-
dba about 5 yearsfor scaling you may add "Stretch=Fill", so it gets scaled to fit the parent container, e.g. Button.Content..) Ok, just spotted it in the answer of @LongZheng :)
-
dba about 5 yearsLayoutTransform could help you out. Maybe the best shot is, to create a Usercontrol with a 'Direction' Dependency Property so you could place it as often you need w/o rewriting the xaml