ResourceDictionary with MVVM and Prism

I created a Prism project with one module. In the module, I defined some views. I want to use ResourceDictionary for user interface element styles.

However ... if I include the following code in View1.xaml I get the following error

Warning 1 The designer does not support loading dictionaries that mix ResourceDictionary elements without a key and other elements in the same collection. Ensure that the Resources property does not contain keyless ResourceDictionary elements or that the ResourceDictionary element is the only element in the collection.

Here is the code:

<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../Resources/ResourceDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> 

If I include the code in the App.xaml file, the style looks applied in the constructor, but when I run the project, I get the following error:

Cannot find resource with name / key

Do you have any helpful tips on how to use ResourceDictionary styles with Prism and MVVM?

thanks

+4
source share

All Articles