I currently define some static resources and a style that uses those resources in my window. I would like to move that markup over to the MainSkin.xaml, and then be able to reference it in all windows in which I need that style.
If I simply move the markup over I get a “Provide value on ‘System.Windows.StaticResourceExtension'” exception. I’m assuming that it cannot find the style I’m referencing? Do I need to merge it/link it somehow?
In WPF and Silverlight, you can create any number of resource dictionaries you need. This is purely a logical organization of resources. There is no difference between resources added into an external resource dictionary and then merged into, for instance,
Page.Resources, and resources added directly intoPage.Resources.In practice, we typically define a number of resource dictionaries:
App.xaml, which makes them automatically available to all pages/windows/user controls in the application.MainSkin.xamlis supposed to be specific toMainWindow(as the name shows). This is a suggestion only, and you are free to do as you want 😉 however in your case, if you have resources that are used in multiple places, I would rather create a global resource dictionary, merge it intoApp.xamland add them there.Cheers,
Laurent