title: dynamically accessing datatemplates
body: <p>I have the following xaml: animationTemplate switches between template1 and template2.</p>
  
  <p>I would like to make this more reusable by putting the animationTemplate in the resource dictionary so multiple controls can use the same animationTemplate. The problem is that animation template has references to template1 and template2 so if I put the animationTemplate in the dictionary I get an error because animationTemplate cant find templates 1 and 2.</p>
  
  <pre><code>    &lt;Window.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="Dictionary1.xaml" /&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;DataTemplate x:Key="template1" /&gt;
          &lt;DataTemplate x:Key="template2" /&gt;
          &lt;DataTemplate x:Key="animationTemplate" /&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Window.Resources&gt;
  &lt;ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource animationTemplate}" /&gt;
  </code></pre>
  
  <p>Is there a better way other then putting all of the template pairs in the dictionary and using a contentTemplateSelector to pick from them? I'd rather not do this (even if its possible because I have event handlers in the templates and I'm not sure how I would remove them)</p>