title: Sharing Application Resources in WPF
body: <p>From <a href="http://msdn.microsoft.com/en-us/library/bb613559.aspx" rel="nofollow">this page</a>, I read:</p>
  
  <blockquote>
    <p>If your application uses custom controls and defines resources in a ResourceDictionary (or XAML Resources node), it is recommended that you either define the resources at the Application or Window object level, or define them in the default theme for the custom controls. Defining resources in a custom control's ResourceDictionary imposes a performance impact for every instance of that control.</p>
  </blockquote>
  
  <p>Ok... now, I have a UserControl that defines the following resources:</p>
  
  <pre><code>&lt;UserControl ...&gt;
      &lt;UserControl.Resources&gt;
          &lt;Namespace:ImagesConverter x:Key="ImagesConverter" ...
          &lt;Storyboard x:Key="AnimationHide" ...
      &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>So, because of the fact I'm creating not less than 100 instances of them at runtime, as the MSDN tutorial says, it would be better to move those resources ad MainWindow or App level. Where's the best location to move them to? MainWindow level, App level or resource file? And why?</p>
  
  <p>And then... how can I use them from their new location? Let's say I have this code inside my UserControl:</p>
  
  <pre><code>m_AnimationHide = (Storyboard)Resources["AnimationHide"];
  </code></pre>
  
  <p>How should I modify it to reflect those changes? And how should I modify the following UserControl XAML snippet instead?</p>
  
  <pre><code>Source="{Binding Source={x:Static Properties:Resources.MyImage}, Converter={StaticResource ImagesConverter}}"
  </code></pre>