Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Xamarin.Forms XAML中绘制路径_C#_Xaml_Xamarin.forms - Fatal编程技术网

C# 如何在Xamarin.Forms XAML中绘制路径

C# 如何在Xamarin.Forms XAML中绘制路径,c#,xaml,xamarin.forms,C#,Xaml,Xamarin.forms,来自Windows Phone Silverlight、WPF和UWP world,我现在正在研究Xamarin.Forms,以便将应用程序移植到iOS和Android。到目前为止,该应用程序的所有图标和徽标都是app.xaml文件中的Path元素。例如: <DataTemplate x:Key="ImageAdd"> <Path Width="30" Height="30" Stretch="Fill" Fill="{StaticR

来自Windows Phone Silverlight、WPF和UWP world,我现在正在研究Xamarin.Forms,以便将应用程序移植到iOS和Android。到目前为止,该应用程序的所有图标和徽标都是
app.xaml
文件中的
Path
元素。例如:

<DataTemplate x:Key="ImageAdd">
    <Path Width="30" 
     Height="30" 
     Stretch="Fill" 
     Fill="{StaticResource TsColorWhite}" 
     Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "/>
</DataTemplate>

使用此功能,应用程序不需要为不同的屏幕分辨率缩放图形

Path
位于
System.Windows.Shapes
命名空间中,因此在XF中不可用


所以问题是:如何在Xamarin.Forms中加载和显示这些路径?

从Xamarin开始。引入了Forms 4.7.0形状,您可以直接在xaml中绘制路径
Aspect
属性相当于Xamarin.Forms中的
Stretch
属性。形状(包括路径)位于
Xamarin.Forms.Shapes
命名空间中

<DataTemplate x:Key="ImageAdd">
    <Path Width="30"
          Height="30"
          Aspect="Fill"
          Fill="{StaticResource TsColorWhite}"
          Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "/>
</DataTemplate>

相关文件
  • Microsoft博客:

  • Microsoft官方文档:

  • GitHub:规格:


在Windows上运行原始应用程序,并拍摄徽标的屏幕截图。另存为.PNG