首页 > 解决方案 > Xamarin.Forms 如何在 App 的所有页面上添加背景图片

问题描述

我需要添加一个背景图像并为其设置样式。该图像必须在我的应用程序的所有页面中继承。如何在资源字典的 App.xaml 中添加?

标签: xamarin.formsxamarin.androidxamarin.ios

解决方案


在您的 App.xaml 中添加如下样式:

 <Style ApplyToDerivedTypes="True" TargetType="Page">
    <Setter Property="BackgroundImage" Value="ImageResource.png" />
 </Style>

对于其他所有样式,您需要为此添加更多内容。

此外,如果您只需要应用ContentPage它,它将替换Page上述样式中的


推荐阅读