title: WPF UserControl Resources
body: <p>I made a <strong>ResourceDictionary</strong> in a WPF User Control Assembly. I Want to be able to use this across this <strong>UserControl</strong> and have all the styles in this separated file.</p>
  
  <p>The ResourceDictionary:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;    
      &lt;Style x:Key="c1BtnX1"&gt;
          &lt;Setter Property="Background" Value="Bisque"&gt;&lt;/Setter&gt;
      &lt;/Style&gt;    
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>It's Address is The User Control Assembly Resources/mainResX.xaml
  and the View is in the same assembly/Views/view.xaml</p>
  
  <p>The usage I think could be:</p>
  
  <pre><code>&lt;Border Style="{StaticResource ResourceKey=c1BtnX1}" 
          BorderBrush="Black"  
          Width="20" 
          Height="20"&gt;
                 &lt;TextBlock Text="X" /&gt;
  &lt;/Border&gt;
  </code></pre>
  
  <p>Also I tried the below code inside the UserControl, to define Per Control Resources but this way also seems it couldn't find the resources.</p>
  
  <pre><code> &lt;UserControl ... &gt;
      &lt;UserControl.Resources&gt;
          &lt;ResourceDictionary Source="../Resources/mainResX.xaml" /&gt;            
      &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>Where and How should I place/Define this ?</p>