Connecting Tech Pros Worldwide Help | Site Map

WPF Application ResourceDictionary problem

  #1  
Old March 13th, 2009, 11:22 AM
Newbie
 
Join Date: Sep 2008
Posts: 22
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.
  #2  
Old July 3rd, 2009, 10:22 AM
Newbie
 
Join Date: Jul 2009
Posts: 1

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: WPF: Custom control and resorce files in a different assembly. Linda Liu[MSFT] answers 7 July 11th, 2008 10:55 AM