title: Style based on StaticResource previously defined is not found at runtime
body: <p>I'm using Telerik's RadControls for WPF with implicit styling. The following style is defined in <code>Themes/Windows8/Telerik.Windows.Controls.RibbonView.xaml</code>:</p>
  
  <pre><code>&lt;Style TargetType="telerikRibbonView:RadRibbonView" x:Key="RadRibbonViewStyle"&gt;
  ...
  &lt;/Style&gt;
  </code></pre>
  
  <p>My own styles and the Telerik default ones get merged like this in the assembly <code>Lib.Windows.Controls</code> in the folder <code>Themes</code>:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
      &lt;ResourceDictionary.MergedDictionaries&gt;
          &lt;ResourceDictionary Source="Windows8/Telerik.Windows.Controls.RibbonView.xaml" /&gt;        
          &lt;ResourceDictionary Source="MyTheme/TelerikCustomizations.xaml" /&gt;
  
          &lt;ResourceDictionary&gt;
              &lt;!-- avoid optimization --&gt;
              &lt;Style TargetType="{x:Type Rectangle}" /&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/ResourceDictionary.MergedDictionaries&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>And in <code>TelerikCustomizations.xaml</code> I define the following (empty, for testing purposes) style:</p>
  
  <pre><code>&lt;Style x:Key="MyThemeRadRibbonViewStyle" TargetType="{x:Type telerik:RadRibbonView}" BasedOn="{StaticResource ResourceKey=RadRibbonViewStyle}" /&gt;
  </code></pre>
  
  <p>Which results in the following exception at runtime:</p>
  
  <p><code>'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.' Line number '4' and line position '42'.
  {"Cannot find resource named 'RadRibbonViewStyle'. Resource names are case sensitive."}</code></p>
  
  <p>Which led me to the following debugging statements in MyView.xaml.cs:</p>
  
  <pre><code>public ShellView()
  {
      var baseStyle = FindResource("RadRibbonViewStyle");
      var inherited = FindResource("MyThemeRadRibbonViewStyle");
      InitializeComponent();
  }
  </code></pre>
  
  <p>Now the thing is: The exception is thrown on the second <code>FindResource</code> call. With the exact same message. However the <code>RadRibbonViewStyle</code> is clearly found in the first line of the constructor.</p>
  
  <p>If it matters, the merged dictionary is actually merged in App.xaml a second time.</p>
  
  <p>I'm sure I'm missing something obvious, but I can't figure out what.</p>
  
  <p><strong>App.xaml</strong></p>
  
  <pre><code>&lt;Application x:Class="TestClient.App"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      StartupUri="Views/ShellView.xaml"&gt;
      &lt;Application.Resources&gt;
        &lt;ResourceDictionary&gt;
            &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="pack://application:,,,/Lib.Windows.Controls;component/Themes/MyTheme.xaml" /&gt;
  
                &lt;ResourceDictionary&gt;
                      &lt;!-- added to avoid optimization --&gt;
                      &lt;Style TargetType="{x:Type Rectangle}" /&gt;
                  &lt;/ResourceDictionary&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
        &lt;/ResourceDictionary&gt;
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p><code>App.xaml.cs</code> does not overwrite the constructor. In fact it does not do anything.</p>
  
  <p><strong>Update</strong></p>
  
  <p>If I merge the Telerik dictionaries in <code>TelerikCustomizations.xaml</code> instead of merging them in yet another dictionary (<code>MyTheme.xaml</code>), the exception disappears.</p>
  
  <p>However, I'd still like to know why this happens.</p>