I have a desktop WPF application that loads it's resources from the web, this allows us to do different things like...add a christmas theme later on down the road around the holidays if we want. To load the Theme, I would just replace the Applications current resource dictionary with our own resource dictionary like so.
ResourceDictionary resources = null;
System.Net.WebClient client = new System.Net.WebClient();
using (Stream s = client.OpenRead("http://www.mywebsite.com/MyXAMLFile.xaml"))
{
try
{
resources = (ResourceDictionary)XamlReader.Load(s);
}
catch
{ }
}
Application.Current.Resources = resources;
Well we got to the point where I wanted to kinda seperate some of the resources into different files instead of using just ONE big resource file that contained everything. I thought this would be rather simple just using merged resources. I thought a simple modification to the code above would make it work, but it turns out it doesn't. This is what I expected I would have to do.
//replace the last line
Application.Current.Resources = resources;
//with this line
Application.Current.Resources.MergedDictionaries.Add(resources);
When the application is run, it just uses the normal styles, and doesn't take into account the merged resources I added. What am I doing wrong here? How am I able to dynamically add merged resources (and multiple ones) at runtime and get them to work properly?
Thanks, Kyle