Reputation: 3243
Suppose I have multiple resource dictionaries and some resources have Dynamic/StaticResource references to resources in the other resource dictionary, is there anyway for them to reference each other without having to use a MergedDictionary to reference the other dictionary?
I thought that merging all resource dictionaries into the Application.Resources would allow all Dynamic/StaticResource references to be resolved to the Application-level, but this gives me an exception that the key is not found so I guess it doesn't work that way?
If these resource dictionaries which depend on resources in the other, reference each other via MergedDictionaries AND I merge these all into the Application.Resources, aren't I then creating duplicates of the same resource dictionaries as separate instances and wasting memory unnecessarily?
Is there a more elegant way to do this?
Upvotes: 0
Views: 114
Reputation: 4742
Here's an implementation of MergedDictionary that caches the ResourceDictionary objects (avoiding the duplication issue.)
http://www.wpftutorial.net/MergedDictionaryPerformance.html
Upvotes: 1