title: DataTemplates in resource dictionaries don't inherit from app.xaml styles?
body: <p>I added custom named styles to the app.xaml.</p>
  
  <p>I created an external resource dictionary (which I attach in the merged dictionaries of the app.xaml) and when I try to use one of the above named styles in the rcource dictionary, it says that there is no such style.</p>
  
  <p>Also the default styles (i.e. unnamed styles that apply for the entire application) don't apply on the template elements.</p>
  
  <p><em>Note: The Build Action of the templates is 'Page'.</em></p>
  
  <hr>
  
  <p>Here is an example of how my code is written:</p>
  
  <pre><code>&lt;Application x:Class="Application"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
      ShutdownMode="OnExplicitShutdown"&gt;
      &lt;Application.Resources&gt;
          &lt;ResourceDictionary&gt;
  
              &lt;Style
                      x:Key="StackPanelStyle" 
                      TargetType="StackPanel" 
                      BasedOn="{StaticResource {x:Type StackPanel}}"&gt;
                  &lt;Setter Property="Margin" Value="5"/&gt;
                  &lt;Setter Property="Orientation" Value="Horizontal" /&gt;
                  &lt;Setter Property="Height" Value="40"/&gt;
              &lt;/Style&gt;
  
              &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="/Templates/DataTemplate1.xaml"/&gt;
                  &lt;ResourceDictionary Source="/Templates/DataTemplate2.xaml"/&gt;
                  &lt;ResourceDictionary Source="/Templates/DataTemplate3.xaml"/&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <hr>
  
  <p>This an example of the data template:
  </p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type Entity}" x:Key="NameDataTemplate"&gt;
      &lt;Expander&gt;
          &lt;StackPanel&gt;
              &lt;--The following line produces: StackPanelStyle was not found.--&gt;
              &lt;StackPanel Style="{StaticResource StackPanelStyle}"&gt;
                  &lt;Label Content="Name:"/&gt;
                  &lt;TextBox Text="{Binding Name}"/&gt;
              &lt;/StackPanel&gt;
          &lt;/StackPanel&gt;
      &lt;/Expander&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>Any ideas?
  Do I have to merge the dictionaries in a different way?</p>