I am making a Windows Phone 7 application and I am a bit confused about dark / light themes.
With panoramas, you very often set a background image. The problem is that it is very difficult to take a picture that is suitable for both dark and light themes. How should we act?
Is there any way to get a dark / light theme for a panorama? This avoids the background image of the panorama for a specific theme. Then how do I do this? I found xaml files in C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Design. If this is the correct way, how can I import them for my panorama?
Or if there is no way (or if it is wrong) to make the theme dark / light: how to write conditional XAML to install the correct resources? Now I have the following XAML (default.xaml) that works great for a dark theme:
<ImageBrush x:Key="PageBackground" ImageSource="Resources/PageBackground.png" Stretch="None" />
<ImageBrush x:Key="PanoramaBackground" ImageSource="Resources/PanoramaBackground.png" Stretch="None" />
But when I use a light theme, black controls and black texts are hard to read with dark background images. Therefore, I took different pictures that I can use as follows:
<ImageBrush x:Key="PageBackground" ImageSource="Resources/PageBackgroundLight.png" Stretch="None" />
<ImageBrush x:Key="PanoramaBackground" ImageSource="Resources/PanoramaBackgroundLight.png" Stretch="None" />
Now my problem is to make XAML conditional in order to declare the right thing depending on the current topic.
I did not find a suitable way on the Internet. I would prefer not to use code or code for this because I believe that XAML can do this (I just don't know how to do this).
EDIT : code snippet for loading xaml file as ResourceDictionary
string xaml = null;
StreamResourceInfo xamlInfo = Application.GetResourceStream(new Uri("light.xaml", UriKind.Relative));
using (StreamReader sr = new StreamReader(xamlInfo.Stream))
xaml = sr.ReadToEnd();
dic = (ResourceDictionary)XamlReader.Load(xaml);
this.Resources.MergedDictionaries.Add(dic);