title: Merged dictionaries and local resources
body: <p>I have a Styles.xaml that groups many <code>ResourceDictionary</code>s inside a <code>MergedDictionary</code>.</p>
  
  <p>I imported Styles.xaml in my <code>UserControl.Resources</code></p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary Source="Dictionaries\Styles.xaml" /&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>but when I try to add a converter </p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="Dictionaries\Styles.xaml" /&gt; &lt;--! Exception --&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>it raises</p>
  
  <blockquote>
    <p>ArgumentNullException: Value cannot be null.<br>
    Parameter name: item</p>
  </blockquote>
  
  <p>Wrapping the converter inside another <code>MergedDictionary</code> has no effect.<br>
  How can I solve this?<br>
  Thank you all!</p>
  
  <hr>
  
  <h3>SOLVED</h3>
  
  <p>I eventually figured it out: the <code>Exception</code> was raised inside one the .xaml files, but Visual Studio does not provide enough info to locate the faulty line.<br>
  Following code does work.</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="Dictionaries\Styles.xaml" /&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>