C# 如何在Xamarin.Forms XAML中绘制路径
来自Windows Phone Silverlight、WPF和UWP world,我现在正在研究Xamarin.Forms,以便将应用程序移植到iOS和Android。到目前为止,该应用程序的所有图标和徽标都是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
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:规格: