title: WPF Ressource Dictionary match DataTemplate, Styles and Views for a Control depending of Type
body: <p>I have problems with matching Ressource Dictionaries for a specific type in my project.</p>
  
  <p>At start of my application my programm takes all .dll files in the folder and bind the .dlls to my project. After that I will search in all Assemblies for .xaml Files also the Ressource Dictionaries in my different dlls. </p>
  
  <p>At the end I got a list with my Ressource Dictionaries.</p>
  
  <p>Okay here is my problem now...How can I select the right dictionary for my type in the list View dynamicly. The second thing is how can I match the Dictionary Templates only to 1 control in my Window? </p>
  
  <p>When the type of the items in my list view are changing check again for the right dictionary maybe i need another one</p>
  
  <p>Here is an example of 1 dictionary</p>
  
  <pre><code>&lt;ResourceDictionary 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:local="clr-namespace:PresentObjectDataTemplate"&gt;
  &lt;Style TargetType="ListView"&gt;
      &lt;!-- My Style for my ListView Control--&gt;
  &lt;/Style&gt;  
  &lt;!-- My Data Templates only for 1 Control--&gt;
  &lt;DataTemplate DataType="{x:Type local:Entity1}"&gt;
      &lt;StackPanel&gt;
          &lt;TextBox Text="{Binding A1}"/&gt;
          &lt;TextBox Text="{Binding A2}"/&gt;
      &lt;/StackPanel&gt;
  &lt;/DataTemplate&gt;
  
  &lt;DataTemplate DataType="{x:Type local:Entity2}"&gt;
      &lt;StackPanel&gt;
          &lt;TextBox Text="{Binding A1}"/&gt;
          &lt;TextBox Text="{Binding A2}"/&gt;
      &lt;/StackPanel&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>My MainWindow has 3 Controls </p>
  
  <ol>
  <li>A treeView to select my List </li>
  <li>A listview to show the objects in the list</li>
  <li>A contentcontrol to show the properties of a selected object</li>
  </ol>
  
  <p>When I merge the dictionary to the window ressources my list view and my content control will use the datatemplates. But i want that the templates only used in the contentcontrol</p>
  
  <p>Here a picture from my idea for better understanding
  <a href="https://i.stack.imgur.com/E2EST.png" rel="nofollow noreferrer">myPicture</a></p>