I use the resource dictionary (the same dictionary) in many converters as a local variable.
var DeignerDictionary = new ResourceDictionary { Source = new Uri(path) };
Every time I create a new instance, and the memory takes up a lot of space in the application.
Then I moved the resource dictionary to a static field and I reused the dictionary, but the styles do not display correctly.
public class resourceDictionaryProvider{ public readonly ResourceDictionary StaticDictionary = new ResourceDictionar {Source = new Uri(path)}; }
Can anyone suggest what I am doing wrong, please submit your suggestions.
The problem occurs after changing the ResourceDictionary as static only. But the following code is working fine.
public class resourceDictionaryProvider{ public static readonly ResourceDictionary StaticDictionary = new ResourceDictionar {Source = new Uri(path)}; }
Now I am creating an instance of the resourceDictionaryProvider class and it works fine, but I do not want to instantiate. So only I changed it to static.
What is the problem with the static keyword?
source share