Wpf 如何使用xaml绘制带箭头和直角的直线
给定xaml中的起点和终点,我可以画一条直线Wpf 如何使用xaml绘制带箭头和直角的直线,wpf,xaml,Wpf,Xaml,给定xaml中的起点和终点,我可以画一条直线 <Grid Padding="40"> <Path x:Name="arcPath" Opacity="1" StrokeThickness="2" Stroke="Red"> <Path.Data> &l
<Grid Padding="40">
<Path
x:Name="arcPath"
Opacity="1"
StrokeThickness="2"
Stroke="Red">
<Path.Data>
<LineGeometry>
<LineGeometry.StartPoint >
<Point X="0" Y="0"/>
</LineGeometry.StartPoint>
<LineGeometry.EndPoint>
<Point X="0" Y="100"/>
</LineGeometry.EndPoint>
</LineGeometry>
</Path.Data>
</Path>
</Grid>
但现在我想添加更多,比如直角和箭头。如何在xaml中实现它
使用路径或多段线至少对于此类箭头,需要四个点的集合:起点、终点和每个角点。计算它们并设置多段线。使用Path在尖端绘制一个小三角形。这些不是用XAMLI编写的。如果不需要使用预定坐标计算直线的轨迹,并且用XAML手工编写所有坐标,那么创建这样的箭头就没有问题。我会告诉你怎么做,但是你的主题已经关闭,不接受回复。对问题进行一些更改(以覆盖关闭原因),并要求打开主题以获取答案。我可以尝试重新打开或创建新问题。谢谢。
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" >
<Path StrokeThickness="2"
Stroke="Red"
Fill="{Binding Stroke, RelativeSource={RelativeSource Self}}">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0 0" IsFilled="False">
<LineSegment Point="20 0"/>
<LineSegment Point="20 100"/>
<LineSegment Point="0 100"/>
</PathFigure>
<PathFigure StartPoint="0 100" IsClosed="True">
<LineSegment Point="10 95"/>
<LineSegment Point="10 105"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</Grid>