wpf VS2013:查找资源字典时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19779776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VS2013: An error occurred while finding the resource dictionary
提问by Andy
I just got VS2013 and opened my VS2010 project. However now I cannot see any of xaml designs. The problem is the Styles are not being applied:
我刚拿到 VS2013 并打开了我的 VS2010 项目。但是现在我看不到任何 xaml 设计。问题是没有应用样式:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Colors.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Gives me the error:
给了我错误:
Error 1 An error occurred while finding the resource dictionary "/Themes/Colors.xaml".
错误 1 查找资源字典“/Themes/Colors.xaml”时出错。
This works fine in VS2010. The build option is set to Page. All target frameworks are set to .NET 4.
这在 VS2010 中工作正常。构建选项设置为 Page。所有目标框架都设置为 .NET 4。
The directory structure is this:
目录结构是这样的:
Host\Themes\Colors.xaml
Plugins\EqPlugin\Source\ProblemFile.xaml
The themes are defined in the VEParameters project and have this declared:
主题在 VEParameters 项目中定义并声明:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EQPlugin;assembly=VEParameterTool">
The file where the error occurs is in the EqPlugIn directory and has this declared:
发生错误的文件位于 EqPlugIn 目录中,并声明了以下内容:
<UserControl x:Class="EQPlugin.EQControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:src="clr-namespace:VEParameterTool;assembly=VEParameterTool"
xmlns:l="clr-namespace:EQPlugin"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:oxy="http://oxyplot.codeplex.com"
mc:Ignorable="d">
I have tried changing the paths to relative paths but that doesn't work, i have removed and re-added the assemblies, i have restarted etc, all projects are build for the same framework. I don't know what else to try.
我尝试将路径更改为相对路径,但这不起作用,我已经删除并重新添加了程序集,我已经重新启动等,所有项目都是为同一个框架构建的。我不知道还能尝试什么。
回答by Kumareshan
Try the below one, Provied the assembly name, even if it is in the same assembly
尝试下面的一个,提供程序集名称,即使它在同一个程序集中
Source="pack://application:,,,/<assemblyName>;component/Themes/Colors.xaml"

