Xamarin.Forms 如何在应用程序的所有页面上添加背景图像 [英] Xamarin.Forms How to add Backgroud Image on all pages in App

查看:44
本文介绍了Xamarin.Forms 如何在应用程序的所有页面上添加背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to add one Background Image and Style it. That image must be inherited in all pages of my app. How to do it add in App.xaml in Resource Dictionary?

推荐答案

要在 App.xaml 中添加背景图片,您可以通过以下方式进行:

To add your background image in App.xaml, you can procede this way:

<?xml version="1.0" encoding="utf-8" ?>
<Application
    x:Class="YourProject.App"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:yourProject="clr-namespace:YourProject;assembly=YourProject">
  <Application ...>
    <Application.Resources>
        <ResourceDictionary>
           <FileImageSource x:Key="MyBackgroundImage">bgImage.jpg</FileImageSource>
        </ResourceDictionary>
    </Application.Resources>
</Application>

然后在你看来,你引用它

And then in your view, you reference it

<Image Source="{ StaticResource MyBackgroundImage}" />

这篇关于Xamarin.Forms 如何在应用程序的所有页面上添加背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆