We use ResourceDictionaries to store layout information for our application. Lazy initialization is excellent, because we can capture the required layout for an element only when this element is created. The problem is that each element gets the same instance from the ResourceDictionary for each of them, which shares the layout (or the same if it goes out of scope and is needed later).
We could store the templates in a dictionary, then it doesnβt matter if they are shared, but we have a pretty good system if it werenβt for this caching behavior.
Is there a way to change this dictionary behavior or will I have to write my own class that creates elements from XAML on request?
source share