Windows Phone的应用背景图片 [英] Windows Phone app background image
本文介绍了Windows Phone的应用背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图更改背景图片在App.xaml中所有的XAML页面,没有成功。
I'm trying to change the background image for all my xaml pages in the app.xaml, unsuccessfully.
我想以下,在App构造器:
I'm trying the following, in the App constructor:
var imageBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri("/Images/SomeBackgroundImage.png", UriKind.Relative))
};
RootFrame.Background = imageBrush;
我不希望在页面级别要做到这一点,因为所有页面都拥有相同的背景在我做错了什么在这里图像根据用户所选的主题。
I don't want to do this at the page level, as all pages will have the same background image depending on the theme selected by the user.
想法?
推荐答案
我最终什么事做:
我创建了一个选择正确的背景图像,这取决于所选择的主题的方法
I created a method that chooses the correct background image, depending on the theme selected.
public static ImageBrush GetBackground()
{
var imageBrush = new ImageBrush();
if ((Visibility)App.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible)
{
imageBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri("/Images/Background1.png", UriKind.Relative))
};
}
else
{
imageBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri("/Images/Background2.png", UriKind.Relative))
};
}
return imageBrush;
}
和在每一页我设置背景图片。
And in each page I set the background image.
LayoutRoot.Background = Utils.GetBackground();
这篇关于Windows Phone的应用背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文