在Visual Studio 2017 Pro中使用通过Nuget安装的MahApps组件时遇到上述错误。视觉设计器不会加载,但是我可以编译并运行代码而没有任何问题。如果我重新启动Visual Studio,该错误将消失,直到应用程序的下一次运行/停止。每次重新加载VS只是为了让设计人员启动并运行是很烦人的。有任何线索吗?
我在非WPF项目(Office加载项)中创建了WPF表单:
<Controls:MetroWindow xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
x:Class="myAddin.Forms.UserPreferencesPopup"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml"/>
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
查找资源字典时发生错误
"pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml".
StackTrace
at Microsoft.VisualStudio.DesignTools.WpfDesigner.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceDictionary(ILocalInstanceBuilderContext context, ViewNode viewNode, IDocumentRoot& relatedRoot, ResourceDictionary& originalInstance)
at Microsoft.VisualStudio.DesignTools.WpfDesigner.InstanceBuilders.ResourceDictionaryInstanceBuilder.UpdateProperty(ILocalInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode)
at Microsoft.VisualStudio.DesignTools.WpfDesigner.InstanceBuilders.ResourceDictionaryInstanceBuilder.InstantiateProperties(ILocalInstanceBuilderContext context, ViewNode viewNode, DocumentCompositeNode compositeNode)
at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.DictionaryInstanceBuilder.Initialize(ILocalInstanceBuilderContext context, ViewNode viewNode, Boolean isNewInstance)
at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.LocalInstanceManager.InitializeInstance(IInstanceBuilder builder, ViewNode viewNode, Boolean isNewInstance)