title: What's the difference between StaticResource and DynamicResource in WPF?
body: <p>When using resources such as brushes, templates and styles in WPF, they can be specified either as StaticResources </p>
  
  <pre><code>&lt;Rectangle Fill="{StaticResource MyBrush}" /&gt;
  </code></pre>
  
  <p>or as a DynamicResource</p>
  
  <pre><code>&lt;ItemsControl ItemTemplate="{DynamicResource MyItemTemplate}"  /&gt;
  </code></pre>
  
  <p>Most of the times (always?), only one works and the other will throw exception during runtime. But I'd like to know why:</p>
  
  <ul>
  <li>What is the main difference. Like memory or performance implications</li>
  <li>Are there rules in WPF like "brushes are always static" and "templates are always dynamic" etc.?</li>
  </ul>
  
  <p>I <strong>assume</strong> the choice between Static vs Dynamic isn't as arbitrary as it seems... but I fail to see the pattern.</p>