Here are two scenarios where merged ResourceDictionary objects are the way forward.

I’m working on a WPF project that needs to be single instance. Heaven forbid that the WPF team should pollute the purity of their framework with support for this kind of thing (or NotifyIcon support but that’s another story) so I’m using the code recommended by Arik Poznanski: WPF Single Instance Application. I like this because it both enforces a single instance and provides an interface that reports the command line passed to any attempt to launch another instance.

An issue with using this code is that you need to write a Main function and so App.xaml is set to Page instead of Application Definition. Once you’ve done this the program works fine but the Visual Studio designer fails to load resources in UserControls (and in Windows containing those UserControls).

The fix is to factor all of the application level resources out into a separate ResourceDictionary (i.e. MergedResources.xaml). Once you’ve done this merge the new ResourceDictionary into App.xaml as follows:

If you’re putting Windows and UserControls in the DLL use exactly the same approach to reference the resources using ResourceDictionary.MergedDictionaries and you’ll get designer support for these as well.

Comments

where should the code <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/MyDll;component/ExternalResources.xaml"> </resourcedictionary></resourcedictionary.mergeddictionaries></resourcedictionary>

be included I mean in which file ? as we don't want to change anything in the parent project, so where should these lines be written?

It has to be added where you're using the resource dictionary. So if you've factored resources out into a DLL you'll have to change the project that uses the DLL to reference it. Not sure what you mean by not changing the parent project.