Use "FindResource" from other application classes
I need to use the FindResource ("key") method. In my MainWindow class, it works.
I have to use it in another class, but I cannot reference it with a new instance of the MainWindow class because it gives me some problem (not relevant now).
So, I declared a static method in my MainWindow class, but this way I cannot use "this" in the static method, I wrote:
public static string getFromDict(string key){
View.MainWindow v = new View.MainWindow();
return v.getResource(key);
}
private string getResource(string key) {
return this.FindResource(key).ToString();
}
This is still causing problems because, as you can see, I am also creating a new MainWindow instance.
So, from another class, how can I use the findResource method? (the resource I want to read is some dicts in the xml included in the project: I have already read them correctly in other code).
+3
source to share