带有 MVVM 和 Prism 的 ResourceDictionary
我已经建立了一个包含一个模块的 Prism 项目。在模块中我定义了一些视图。我想使用 ResourceDictionary 来设置 UI 元素的样式。
但是...如果我在 View1.xaml 中包含以下代码 我收到以下错误
警告 1 设计器不支持加载混合没有键的“ResourceDictionary”项目和同一集合中的其他项目的词典。请确保“Resources”属性不包含没有键的“ResourceDictionary”项,或者“ResourceDictionary”项是集合中的唯一元素。
这是代码:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/ResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
如果我在 App.xaml 文件中包含代码,样式看起来会应用在设计器中,但是当我运行项目时,会出现以下错误:
找不到具有名称/密钥的资源
您对如何在 Prism 和 MVVM 中使用 ResourceDictionary 样式有任何有用的建议吗?
谢谢
I have set up a Prism project with one module. In the module I have defined some views. I want to use a ResourceDictionary to style UI elements.
However...if I include the following code in the View1.xaml
i get the following error
Warning 1 The designer does not support loading dictionaries that mix 'ResourceDictionary' items without a key and other items in the same collection. Please ensure that the 'Resources' property does not contain 'ResourceDictionary' items without a key, or that the 'ResourceDictionary' item 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 designer, but when I run the project i get the following error:
Cannot find a Resource with the Name/Key
Do you have any useful advices how to use ResourceDictionary styles with Prism and MVVM?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这里的这个人也有类似的问题:
http://blog.caraulean.com/2011/09/13/how-to-make-caliburn-micro-and-silverlight-resources-in-mergeddictionaries-play-nicely-together/
检查一下
Maybe this guy here had a similar problem:
http://blog.caraulean.com/2011/09/13/how-to-make-caliburn-micro-and-silverlight-resources-in-mergeddictionaries-play-nicely-together/
Have a check