.net 仅使用 XAML 绘制纯色三角形

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7874822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 15:59:07  来源:igfitidea点击:

Draw solid color triangle using XAML only

.netwpfxamldraw

提问by sll

Is it possible to draw a filled in triangle using XAML only (not a code behind solution)?

是否可以仅使用 XAML 绘制实心三角形(不是解决方案背后的代码)?

Triangle should be like on the image below to represent sort direction Ascending/Descendingalong with a sort button on a chart control:

三角形应如下图所示,以表示排序方向Ascending/Descending以及图表控件上的排序按钮:

enter image description here

在此处输入图片说明

EDIT:The solution, thanks to SpeziFish:

编辑:解决方案,感谢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" />

回答by SpeziFish

<Polygon Points="0,0 80,50, 0,100" Stroke="Black" Fill="Black" />

See APIor Example.

请参阅API示例

回答by Vladimir Trifonov

I want to add these to their collection:

我想将这些添加到他们的收藏中:

enter image description here

在此处输入图片说明

    <Polygon Points="5,0 10,10, 0,10" Stroke="Black" Fill="Black" />

enter image description here

在此处输入图片说明

    <Polygon Points="0,0 5,10, 10,0" Stroke="Black" Fill="Black" />

回答by LongZheng

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 "/>