我是Xamarin Forms的新手,我来自WPF。在WPF中,很容易将背景图像(远程)设置为形状。 Xamarin表单中是否有任何等效的东西?
答案 0 :(得分:2)
将形状和路径引入Xamarin.Forms之后,您可以在Grid中实现它:
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Ellipse Stroke="blue" StrokeThickness="5" Fill="Black" Aspect="Fill"/>
<Image Source="xamarin.png" WidthRequest="300" HeightRequest="300"/>
</Grid>
带有Frame
的圆角:
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Frame WidthRequest="200" CornerRadius="80"
BackgroundColor="Black" HeightRequest="200"/>
<Image Source="xamarin.png" WidthRequest="200" HeightRequest="200"/>
</Grid>
使用Path
:
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Path Stroke="blue"
Data="m123.87668,219.80811l21.30223,-42.92685l36.89384,-24.78565l42.60447,0l36.89384,24.78565l21.30223,42.92685l0,49.57131l-21.30223,42.92685l-36.89384,24.78564l-42.60447,0l-36.89384,-24.78564l-21.30223,-42.92685l0,-49.57131z"
StrokeThickness="5" WidthRequest="200" HeightRequest="200"
Aspect="Fill" Fill="Black"/>
<Image Source="xamarin.png" WidthRequest="200" HeightRequest="200"/>
</Grid>
Microsoft博客:Drawing UI with Xamarin.Forms Shapes and Paths。
Microsoft官方文档:Xamarin.Forms Shapes。
GitHub:规范:Shapes & Paths