2012-08-22 174 views
16

我正在尝试引用MergedDictionaries.SharedStyles项目,它具有必须使用allover应用程序的所有样式。所以在这里,我在资源词典的不同文件夹下有不同的样式。所以最后我已经将它们合并到了AllSharedStyles.xaml中,并且在Styles项目级别进行了合并。如何在ResourceDictionary的源代码中设置相对路径/ Uri

现在我在解决方案级<>上有另一个ResourceDictionary,它指的是AllSharedStyles.xaml资源字典< < >>。此ResourceDictionary作为链接添加到解决方案中的所有模块。这里

问题是我SharedResourceDictionary我有以下MergedDictionaries

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="/MergedDictionaries.SharedStyles;component/AllSharedStyles.xaml" /> 
    <ResourceDictionary Source="/View/LocalResource.xaml" /> 
</ResourceDictionary.MergedDictionaries> 

Project architecture

我已经refered到公共资源第一,然后我的本地序覆盖(仅在必要时)特定于模块的任何样式。

现在,当我运行应用程序,报告说

'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '5' and line position '10'. 

那是错误消息。

我的理解是寻找适当的参考。我也尝试使用Pack URL ref:Pack URLss。 这里是包网址:

<ResourceDictionary Source="pack://application:,,,/MergedResourceDictionaries.Styles;component/component/AllSharedStyles.xaml" /> 

所以对此处有一个相对路径的任何建议????

对不起,我的问题

回答

20

我的描述/投影终于摸索出解决办法:

<ResourceDictionary Source="../SharedResourceDictionary.xaml" /> 

将其改为相对路径和给定的根路径。

相关问题