I have a requirement to load and merge ResourceDictionaries
in code at runtime according to certain configuration options. Merging the dictionaries in the Application.OnStartup
method works fine of course, at runtime.
Visual studio's design mode doesn't load your custom Application class, and the only way I know of to get the dictionaries through in DesignMode is by merging them in App.xaml.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SomeDictionary1.xaml" />
<ResourceDictionary Source="SomeDictionary2.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
This however is not viable in my current situation. So what I'm asking is, what does visual studio actually do to load the merged dictionaries from App.xaml to the design surface at the application scope without constructing your custom Application class? And how can I merge these dictionaries from code to application scope in design mode to actually solve the problem?