I have never been able to get this format of reference a Resource Dictionary to work. What am I missing.
Scenario:
Creating and assembly with some usercontrols in it.
At root have said file {root}/Themes/ColorThemes.xaml
The ColorThemes.xaml file has its build action set to Resource.
Then in in xaml file further down let say {root}/Controls/ButtonStyles/Themes/ButtonThemes.xaml (note the path is just an example)
in this file I have the following bit of code:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Themes/ColorThemes.xaml"/>
</ResourceDictionary.MergedDictionaries>
As far as the documentation states this should work (as I understand it), and while I am in the designer it seems to be fine (all the colors load etc) however when I then go and compile my application and run it I get this error {"Cannot locate resource 'themes/colorthemes.xaml'."} which is strange because it seemed to be using just fine in the builder. So I am quiet confused because it seems to not coincide with the documentation.
So if someone can explain to me what I am missing :)
Note: if I change the previous code to
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../../Themes/ColorThemes.xaml"/>
</ResourceDictionary.MergedDictionaries>
It works fine, however for cleanese pack://application: .
try:
pack://application:,,,/YOURNAMESPACEHERE/ColorThemes.xaml
E.g.
pack://application:,,,/Themes/ColorThemes.xaml
Can't reproduce your problem. All these variations 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 complete minimal example which reproduces your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With