title: How to combine imported and local resources in WPF user control
body: <p>I'm writing several WPF user controls that need both shared and individual resources.</p>
  
  <p>I have figured out the syntax for loading resources from a separate resource file:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary Source="ViewResources.xaml" /&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>However, when I do this, I cannot also add resources locally, like:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary Source="ViewResources.xaml" /&gt;
      &lt;!-- Doesn't work: --&gt;
      &lt;ControlTemplate x:Key="validationTemplate"&gt;
          ...
      &lt;/ControlTemplate&gt;
      &lt;style x:key="textBoxWithError" TargetType="{x:Type TextBox}"&gt;
          ...
      &lt;/style&gt;
      ...
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>I've had a look at ResourceDictionary.MergedDictionaries, but that only lets me merge more than one external dictionary, not define further resources locally.</p>
  
  <p>I must be missing something trivial?</p>
  
  <p>It should be mentioned: I'm hosting my user controls in a WinForms project, so putting shared resources in App.xaml is not really an option.</p>