我使用NuGet的MahApps.Metro已有一段时间,没有任何问题。但是,最近我遇到了一些与NuGet软件包有关的问题,需要重新安装。
最后,我卸载了所需的所有NuGet软件包,然后重新安装了它们。据我所知,现在一切正常,但是当我尝试启动该应用程序时,它立即引发上述异常:
System.Windows.Markup.XamlParseException: ''Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '34' and line position '18'.'
Inner Exception
IOException: Cannot locate resource 'styles/colors.xaml'.
如果我检查那些指定的行,就是这个<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
。
我的App.xaml看起来像这样:
<Application.Resources>
<ResourceDictionary>
<!-- Some other stuff is here -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Bunch of other stuff here -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
我从其他类似的问题中尝试过各种方法:
StartupUri
是正确的Assembly name
和Default namespace
不同(并且一直存在)我完全不知道下一步该怎么做...
我没尝试过的一件事是使用旧版本...然后是MahApps.Me的2.0.0版,Metro改变了主题的制作方式。使用1.6.5版可以解决此问题,或者您需要在此处按照迁移指南进行操作:https://mahapps.com/docs/guides/migration-to-v2.0