I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on this article).
I\'ve created several windows, and am now attempting to create a common style
Dr. WPF (or the person formerly known as Dr. WPF) has a great post on the subject.
Here's an excerpt from the post where they create the Application object and add resources:
if (Application.Current == null)
{
// create the Application object
new Application();
// merge in your application resources
Application.Current.Resources.MergedDictionaries.Add(
Application.LoadComponent(
new Uri("MyLibrary;component/Resources/MyResourceDictionary.xaml",
UriKind.Relative)) as ResourceDictionary);
}
Since my assembly is hosted via interop I had to add setting the ShutdownMode as follows and shutdown when finished:
new Application() { ShutdownMode = ShutdownMode.OnExplicitShutdown };
It worked like a charm.