How to add ResourceDictionary defined in a subfolder in App.xaml?

All the code samples that I have found so far refer to a resource dictionary that is not in the project subfolder (the dictionary is in the root of the project). I have mine in a subfolder and I cannot figure out how to get WPF to find it. This does not work...

<Application.Resources> <ResourceDictionary Source="/Skins/Black/GlossyButtons.xaml"/> </Application.Resources> 

ASP.Net caption syntax also does not work.

Is this the best way to include ResourceDictionary in your application so that WPF can find resources? My goal in this particular case is to apply the style defined in GlossyButtons.xaml to all the buttons in my application.

+6
wpf resourcedictionary
source share
2 answers

A problem was found - WPF could not find the assembly specified in GlossyButtons.xaml, but did not display the actual error (there was a problem with .xaml) until I compiled and executed several times. At first the error was displayed: GlossyButtons.xaml could not be found.

It was a bit confusing.

+5
source share

Try package URI syntax

http://msdn.microsoft.com/en-us/library/aa970069.aspx

 <Application.Resources> <ResourceDictionary Source="pack://application:,,,/Skins/Black/GlossyButtons.xaml"/> </Application.Resources> 
+5
source share

All Articles