我有一个Windows 8.1(WinRT)应用程序和一些UI类库,我正在尝试将ResourceDictionaries合并到一起以更好地分割我的资源。我有以下三个项目资源:
Framework.UI.Universal(通用类库)
这是此项目中Themes文件夹中包含的Generic.xaml文件:
<ResourceDictionary>
<!-- Contains some resources used by Windows and Windows Phone -->
</ResourceDictionary>
Framework.UI.Windows(Windows类库)
这是此项目中Themes文件夹中包含的另一个Generic.xaml文件。正如您所看到的,我正在合并来自通用项目的资源字典,以及添加其他资源。
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Framework.UI.Universal/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- Contains Windows specific resources -->
</ResourceDictionary>
MyApp.Windows(Windows 8.1应用程序项目)
这是我的Windows 8.1应用程序。我正在将Windows特定资源字典合并到App.xaml文件中,以及添加特定于应用程序的资源。
<Application x:Class="CurrencyConverter.Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:InfrastructureViews="using:Infrastructure.Client.Views"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Framework.UI.Windows/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- Contains Windows app specific resources -->
</ResourceDictionary>
</Application.Resources>
</Application>
理论上这应该可行,但我在启动时遇到异常,并出现以下错误消息:
在合并的资源词典中检测到循环
答案 0 :(得分:1)
将Universal项目中的Generic.xaml重命名为UniversalGeneric.xaml解决了这个问题。这似乎是一个WinRT错误。