WPF ResourceDictionary Syntax
The current top-hit on
WPF ResourceDictionary on
Google has a minor error in the usage of WPF’s
ResourceDictionary class. Hopefully I can save someone the ten minutes of hate I had while searching for the cause of the strange error the Studio threw at me.
Wrong:
<application.Resources>
<resourceDictionary>
<resourceDictionary.MergedDictionaries>
<resourceDictionary Source="TextStyle.xaml" />
</resourceDictionary.MergedDictionaries>
</resourceDictionary>
<!-- other styles can appear in the resource dictionary too -->
<style TargetType="{x:Type Button}"
x:Key="ButtonStyle">
<setter Property="Background"
Value="#feca00" />
</style>
</application.Resources>
Right:
<application.Resources>
<resourceDictionary>
<resourceDictionary.MergedDictionaries>
<resourceDictionary Source="TextStyle.xaml" />
</resourceDictionary.MergedDictionaries>
<!-- other styles can appear in the resource dictionary too -->
<style TargetType="{x:Type Button}"
x:Key="ButtonStyle">
<setter Property="Background"
Value="#feca00" />
</style>
</resourceDictionary>
</application.Resources>
Note the difference in where the additional
<Style>s go.