Windows Phone app background image
c#, windows-phone-7
Solution
What I ended up doing:
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();
Problem
I'm trying to change the background image for all my xaml pages in the app.xaml, unsuccessfully. 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. Ideas on what I'm doing wrong here?