您的位置:首页 > 其它

WPF异常:在“System.Windows.Markup.StaticResourceHolder”上提供值时引发了异常。

2016-04-22 16:27 351 查看
异常背景:

  第一次开发 WPF 时,所有资源都定义在 App.xaml 文件中。随着项目资源的增多,查看与修改资源时很麻烦,就在 App.xaml 以集成资源字典的方式。

异常原因:

  在 App.xaml 中定义资源时,我把项目中需要使用的 Class 都写在最上面   

<ResourceDictionary
xmlns:app ="clr-namespace:TZCloud"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...
</ResourceDictionary>


资源字典 - 其它

<Application.Resources>
  <ResourceDictionary >
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="Dictionary\Other.xaml"/>
      <ResourceDictionary Source="Dictionary\Class.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources>


  因为 Class 资源声明在后,而其它资源声明(该资源中有对 Class 资源的引用 )在前,所以报错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: