Pack: // application: ,, / ResourceFile.xaml Never Works

I could never get this resource dictionary link format to work. What am I missing.

Scenario:

Create and build with some user controls.
The root file is {root} /Themes/ColorThemes.xaml
The ColorThemes.xaml file has an assembly action set to Resource .
Then in the xaml file further down say {root} /Controls/ButtonStyles/Themes/ButtonThemes.xaml (note that the path is just an example) in this file I have the following code bit:

<ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Themes/ColorThemes.xaml"/> </ResourceDictionary.MergedDictionaries> 

As for the documentation , this should work (as I understand it), but while I am in the designer, everything seems to be in order (all colors are loaded, etc.), however, when I go to compile my application and run it, I I get this error {"Unable to find resource 'themes / colorthemes.xaml'. "}, which is strange because it seemed to be used very well in the builder. Therefore, I am confused because it does not match the documentation.
Therefore, if someone can explain to me what I am missing :)

Note: if I changed the previous code to

 <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../../../Themes/ColorThemes.xaml"/> </ResourceDictionary.MergedDictionaries> 

It works fine, however for cleanese pack: // application :.

+6
source share
2 answers

to try:

 pack://application:,,,/YOURNAMESPACEHERE;component/Themes/ColorThemes.xaml 
+13
source

Unable to reproduce your problem. All of these options work fine:

 <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Themes/ColorThemes.xaml"/> <ResourceDictionary Source="/Themes/ColorThemes.xaml"/> <ResourceDictionary Source="../../Themes/ColorThemes.xaml"/> </ResourceDictionary.MergedDictionaries> 

Note that pack://application:,,, is optional, and / refers to the root of the current assembly.

Please provide a complete minimal example that reproduces your problem.

+7
source

All Articles