Connecting Tech Pros Worldwide Forums | Help | Site Map

WPF Application ResourceDictionary problem

Newbie
 
Join Date: Sep 2008
Posts: 22
#1: Mar 13 '09
Hi all,
I am writing a WPF application which uses styles to visualize controls in the application. I use separate resource dictionaries. ControlTemplates.xaml, Animations.xaml and a folder named Colors including different resource dictionaries to change the control colors on the fly. I am using MergedDictionaries to load styles such that;

Quote:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Styles;component/Styles/Colors/BlueColors.xaml"/>
<ResourceDictionary Source="/Styles;component/Styles/Animations.xaml"/>
<ResourceDictionary Source="/Styles;component/Styles/ControlTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
Then i get an exception when loading resources like;

"A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Cannot find resource named '{BackgroundBrush}'. Resource names are case sensitive. Error at object 'System.Windows.Media.Animation.SplineColorKeyFram e' in markup file 'Styles;component/Styles/Animations.xaml' Line 81 Position 34."

When i add the BlueColors.xaml resource dictionary in the Animations.xaml file everything works well. I need to use those resource dictioaries in separate files because all resources except color resources are common throughout the application.

Any help would be greatly appreciated.

Newbie
 
Join Date: Jul 2009
Posts: 1
#2: Jul 3 '09

re: WPF Application ResourceDictionary problem


In dictionary ControlTemplates add this to the beginning:

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Styles;component/Styles/Colors/BlueColors.xaml"/>
</ResourceDictionary.MergedDictionaries>
Reply