title: Apply themes to wpf and use styles
body: <p>I am trying to apply a theme to a bunch of wpf projects. There is one assembly containing the generic.xaml and different applications. As far as i understand i can't use the ThemeInfo attribute with ResourceDictionaryLocation.ExternalLocation because the name have to be the same as my program but I have more than one program...</p>
  
  <p>So I search and found that I only have to include the dictionary as MergedDictionary in the app.xaml</p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="/ClassLibrary1;component/Themes/generic.xaml" /&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p>This basically works. But if I use a style for the controls it will not apply the generic.xaml style anymore:</p>
  
  <p>generic.xaml in ClassLibrary1.dll</p>
  
  <pre><code>&lt;ResourceDictionary x:Class="ClassLibrary1.Themes.generic"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  
  &lt;Style TargetType="{x:Type Button}"&gt;
      &lt;Setter Property="Background"
              Value="Black" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p></p>
  
  <p>Window in program</p>
  
  <pre><code>&lt;Window x:Class="Theming.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
  
      &lt;Window.Resources&gt;
          &lt;Style TargetType="Button"
                 x:Key="ButtonGreenTextStyle"&gt;
              &lt;Setter Property="Foreground"
                      Value="Green" /&gt;
          &lt;/Style&gt;
      &lt;/Window.Resources&gt;
  
      &lt;Grid&gt;
          &lt;Button Style="{DynamicResource ButtonGreenTextStyle}" Content="Test" /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>What I have to do, that WPF will understand the style in my generic.xaml as basestyle for all buttons (I know I will also have to write a ControlTemplate; the above code is just for simplicity)</p>