【发布时间】:2014-09-26 17:28:51
【问题描述】:
我在项目中有以下文件夹结构:
Style
MainStyles.xaml
MainPage.xaml
在 MainPage.xaml 中,我尝试从 MainStyles 加载资源:
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Style\MainStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
但是,我收到以下错误消息:
WinRT information: Failed to assign to property '%0'. [Line: 13 Position: 37]
Additional information: The text associated with this error code could not be found.
第 13 行和第 37 位是 Source="... 的确切位置。如果我将资源移动到与 MainPage 相同的目录并删除该目录,一切正常。
顺便说一句,Visual Studio 设计师不会抱怨缺乏资源并正确使用它们。
我做错了什么?
【问题讨论】:
-
尝试做两件事:1) 使用正斜杠,'
/'。 2) 添加一个前导正斜杠,'/Style/MainStyles.xaml'。 -
@NateDiamond 正斜杠有效。这很奇怪:) 谢谢!如果您希望我接受,可以将其发布为答案。
标签: resources windows-phone windows-store-apps windows-phone-8.1 resourcedictionary