Drawing arrow with XAML

☆樱花仙子☆ 提交于 2019-12-20 20:02:46

问题


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.


回答1:


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



回答2:


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:

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>


来源:https://stackoverflow.com/questions/30476257/drawing-arrow-with-xaml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!