Can you define ResourceDictionary.MergedDictionary along with other (local) resources in <Windows.Resources>?
I would like to refer to MergedDictionary along with locally declared resources in my Windows.Resources. However, I get this error:
"All objects added to an IDictionary must have a Key attribute or some other type of key associated with them."
Is it possible to mix local resources together with imported resources in the same Window.Resources?
XAML:
<Window.Resources> <CollectionViewSource x:Key="cvsData" Source="{Binding Path=Data}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="Country"/> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary x:Name="images" Source="pack://application:,,,/CoreWpfControls;component/Images.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> Thanks Jeremy
+11
Jeremy holt
source share1 answer
Yes, it is actually very simple. You just need to move additional resources inside the ResourceDictionary element.
<Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/CoreWpfControls;component/Images.xaml"/> </ResourceDictionary.MergedDictionaries> <CollectionViewSource x:Key="cvsData" Source="{Binding Path=Data}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="Country"/> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> </ResourceDictionary> </Window.Resources> +29
Josh
source share