Drawing arrow with XAML

2020-06-03 06:44发布

I don't know how can I draw an arrow with XAML. I haven't any code at the moment.

Someone can help me to make this draw with XAML code ?

Thank you for your help.

标签: xaml drawing
2条回答
Luminary・发光体
2楼-- · 2020-06-03 07:06

I just draw one through setting point by hand and adjust the point by eyes:

<Path Stretch="Fill" Fill="LimeGreen" 
              Data="M
              0,115   95,115   //p1, p2  (when really use remove these comments)
              65,90   85,90    //p3, p4
              120,120          //p5
                      85,150  65,150  //p6, p7
                      95,125  0,125   //p8, p9
              Z"
              HorizontalAlignment="Center"  Width="60" Height="60" />

You can adjust width/height, Basically p1,p2,p3,p4 and p6,p7,p8,p9 are symmetric, and Data can omit description and comma like this:

Data="M 0 115 95 115 65 90 85 90 120 120 85 150 65 150 95 125 0 125 Z"

The result:

enter image description here

Besides here's a way to Rotate the arrow, example below rotate another right arrow 180 degree, becoming a left arrow:

    <Path Stretch="Fill" Fill="LimeGreen" 
          Data="M 0,110 70,110 45,90 75,90 120,120 75,150 45,150 70,130 0,130 Z"
          HorizontalAlignment="Right"  Width="30" Height="24" Margin="0,0,2,0"
          RenderTransformOrigin=".5,.5">
        <Path.RenderTransform>
            <RotateTransform Angle="180" />
        </Path.RenderTransform>
    </Path>
查看更多
Summer. ? 凉城
3楼-- · 2020-06-03 07:18

You can use TextBlock (http://xahlee.info/comp/unicode_arrows.html)

<TextBlock Text="&#x2794;" />

Or Path (https://msdn.microsoft.com/en-us/library/system.windows.shapes.path%28v=vs.110%29.aspx)

<Path Stroke="Black" Data="M 0 4 L 16 4 L 10 0 M 16 4 L 10 8" />
查看更多
登录 后发表回答