Answer the question
In order to leave comments, you need to log in
How to refer to a ResourceDictionary located in a DLL using a URI?
I have a DLL in it is ResourceDictionary SomeDict.xaml. There is also a static method inside which the dictionary is accessed.
There are two applications:
1. Console application
2. WPF
application These applications access the library's static method and directly access the resource dictionary themselves.
Everywhere used identical code for accessing dictionaries.
ResourceDictionary res = new ResourceDictionary();
try
{
res.Source = new Uri("ClassLibrary1;component/SomeDict.xaml", UriKind.Relative);
var l = res["SomeKey"];
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
Answer the question
In order to leave comments, you need to log in
According to Stanislav's link, I decided like this
var uriSchemePack = PackUriHelper.UriSchemePack;
if (Application.Current == null)
{
var application = new Application();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question