我试图设置ContentsPage BackgroundImage但是在大屏幕设备上图像保持平铺。
有没有人知道如何停止平铺图像?
EDITED
以下是iPad上发生的最新情况。
这就是手机上的样子:
MainPage.cs
namespace Application.Views
{
public partial class MainPage : ContentPage
{
RegisterDevice registerDevice;
MenuAnimations menuAnimations;
private double width;
public MainPage()
{
InitializeComponent();
registerDevice = new RegisterDevice();
menuAnimations = new MenuAnimations();
ToolbarItems.Add(new ToolbarItem
{
Icon = "menuBtn.png",
Order = ToolbarItemOrder.Primary
});
}
protected override void OnSizeAllocated(double width, double height)
{
BackgroundImage = "bg_portrait.png";
}
}
}
MainPage.xaml中
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Application.Views.MainPage">
<ContentPage.Content>
</ContentPage.Content>
</ContentPage>
答案 0 :(得分:2)
关于BackgroundImage
属性属于string
类型,我无法使用<Image>
,Aspect
的属性。所以我最好在XAML
:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SuperForms.Samples.Page1">
<ContentView>
<Image Source="https://i.stack.imgur.com/ajyCo.png"
Aspect="AspectFill"/>
</ContentView>
</ContentPage>