Style based on StaticResource previously defined is not found at runtime
I'm using Telerik's RadControls for WPF with implicit styling. The
following style is defined in
Themes/Windows8/Telerik.Windows.Controls.RibbonView.xaml:
<Style TargetType="telerikRibbonView:RadRibbonView"
x:Key="RadRibbonViewStyle">
...
</Style>
My own styles and the Telerik default ones get merged like this:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="Windows8/Telerik.Windows.Controls.RibbonView.xaml" />
<ResourceDictionary Source="MyTheme/TelerikCustomizations.xaml" />
</ResourceDictionary.MergedDictionaries>
And in TelerikCustomizations.xaml I define the following (empty, for
testing purposes) style:
<Style x:Key="MyThemeRadRibbonViewStyle" TargetType="{x:Type
telerik:RadRibbonView}" BasedOn="{StaticResource
ResourceKey=RadRibbonViewStyle}" />
Which results in the following exception at runtime:
'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."}
Which led me to the following debugging statements in MyView.xaml.cs:
public ShellView()
{
var baseStyle = FindResource("RadRibbonViewStyle");
var inherited = FindResource("MyThemeRadRibbonViewStyle");
InitializeComponent();
}
Now the thing is: The exception is thrown on the second FindResource call.
With the exact same message. However the RadRibbonViewStyle is clearly
found in the first line of the constructor.
If it matters, the merged dictionary is actually merged in App.xaml a
second time.
I'm sure I'm missing something obvious, but I can't figure out what.
No comments:
Post a Comment