I am writing several WPF user controls that need both shared and individual resources.
I understood the syntax for loading resources from a separate resource file:
<UserControl.Resources> <ResourceDictionary Source="ViewResources.xaml" /> </UserControl.Resources>
However, when I do this, I cannot also add resources locally, for example:
<UserControl.Resources> <ResourceDictionary Source="ViewResources.xaml" /> <ControlTemplate x:Key="validationTemplate"> ... </ControlTemplate> <style x:key="textBoxWithError" TargetType="{x:Type TextBox}"> ... </style> ... </UserControl.Resources>
I looked at ResourceDictionary.MergedDictionaries, but this only allows me to combine more than one external dictionary, rather than define additional resources locally.
Do I need to miss something trivial?
It should be noted: I host my user controls in a WinForms project, so hosting shared resources in App.xaml is not really an option.
resources wpf xaml
Tor Haugen Aug 26 '09 at 10:37 2009-08-26 10:37
source share