Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you reference a XAML DictionaryResource from an external Assembly?
    primarykey
    data
    text
    <p>I'm a total Nubie to the world of WPF. I'm just starting to get immersed in it.</p> <p>I've got an issue I'm trying to figure out with using ResourceDictionary and Merged Dictionaries.</p> <p>I've got WPF sample application that I've converted to a Class Library. That newly converted assembly is included/referenced in a library of user controls that I'm trying to create. That converted assembly is included a project in the solution containing my user control library (dll) project.</p> <p>I was able to convert it successfully and got rid of all the errors except for some issues with the ResourceDictionary.</p> <h2>This is what the offending XAML looks like:</h2> <pre><code>&lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="/ConvertedAppPath/Dictionaries/Brushes.xaml" /&gt; &lt;ResourceDictionary Source="/ConvertedAppPath/Dictionaries/Styles.xaml" /&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>The original WPF application had several Resource Dictionary items included in the assembly. </p> <h1>When I converted to a class library, I'm getting the following error message on resource dictionary:</h1> <p>Error 21 An error occurred while finding the resource dictionary "/ConvertedAppPath/Dictionaries/Brushes.xaml". C:\MyExplicitPath\WPFUserControls\DynamicDataChart.xaml 15 17 WPFUserControls Error 22 An error occurred while finding the resource dictionary "/ConvertedAppPath/Dictionaries/Styles.xaml". C:\MyExplicitPath\WPFUserControls\DynamicDataChart.xaml 15 17 WPFUserControls</p> <h2>So, I thought that perhaps I needed a relative path for the ResourceDictionaries.</h2> <pre><code>&lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="../ConvertedAppPath/Dictionaries/Brushes.xaml" /&gt; &lt;ResourceDictionary Source="../ConvertedAppPath/Dictionaries/Styles.xaml" /&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; </code></pre> <h2>I get the following error message(s) inside the XAML editor:</h2> <p>The file "../ConvertedAppPath/Dictionaries/Brushes.xaml" is not part of the project or it's Build Action property is not set to "Resource".</p> <h2>I'd really like to understand this, so I've got a couple of questions:</h2> <p>1) How do I clean this up to get rid of the errors?</p> <p>2) Do I need to explicitly set the assembly location in "Source"?</p> <p>3) What are all the pieces of the "Source" property and what do they really mean?</p> <p>4) Why did the 2nd error message not get displayed at compile time, but is visible only in the XAML editor? </p> <p>Thanks for your response and efforts, JohnWPFNewB </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload