尝试在 Expression-Blend 4 中打开在 Visual Studio 2010 中创建的 WPF 项目时出现问题
我在 VS 2010 中创建 WPF 项目。在完成功能性 GUI 的工作后,我想在 Blend 4 中编辑控件模板。但是当我在 Blend 中的 DesignMode 中打开项目时,他告诉我
无效XAML
在结果窗口中,他写道:
Windows Presentation Foundation (WPF) 项目不支持 [ControlName]
其中 [ControlName] 是我在项目中使用的默认控件列表(例如Window、DockPanel 等)
如何避免此问题并能够在 Expression-Blend4 的 DesignMode 下编辑 WPF 表单?
编辑:
可能的解决方法。
对由 Blend
和 Studio 创建的空项目(*.csproj 文件)进行一些比较后
,我发现 VisualStudio
使用下一行创建它:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
...
而 Blend 使用以下行:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
因此,如果将 x86
更改为 AnyCPU< /code>, Blend 将打开项目正如预期的那样。
I'm create my WPF project in VS 2010. After I finished my work with functional GUI, I wanted to edit template of my controls in Blend 4. But when I open project in Blend, in DesignMode, he tell me
Invalid XAML
In Result window he wrote:
[ControlName] is not supported in a Windows Presentation Foundation (WPF) project
Where [ControlName] is list of default controls, which I have used in my project (such as Window, DockPanel, etc.)
What to do to avoid this issues and be able to edit WPF forms at DesignMode of Expression-Blend4?
EDIT:
Possible workaround.
After some comparasion of empty projects (*.csproj file), which was created by Blend
and by Studio
, I have find out that VisualStudio
create it with next line:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
...
while Blend uses the following lines:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
So, if you change x86
to AnyCPU
, Blend will open project as expected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前只见过一次这个错误消息。将新的解决方案文件与无法加载的解决方案文件进行比较后,我发现 Blend 需要定义
AnyCPU
平台/配置。如果这不起作用,请确保您拥有 WPF 项目引用的所有必需程序集:
PresentationCore
、PresentationFramework
和WindowsBase
。哈特哈,
I have only seen this error message once before. After comparing a new solution file with the one that wouldn't load I discovered that Blend requires the
AnyCPU
platform/configuration to be defined.If that does not work, ensure that you have all the required assemblies referenced for a WPF project:
PresentationCore
,PresentationFramework
, andWindowsBase
.HTH,
经过浪费一天的时间跟踪后,我发现了这一点:
在文本编辑器中打开 .proj 文件并查看文件的最顶部,XML 中将有一个 PropertyGroup 部分的列表。看一下第一个,如果它显示 x86 或 AnyCPU 以外的任何内容,请将其更改为 AnyCPU 并保存。
应该是:
为什么?我不是 100% 确定,但 Visual Studio 似乎不会修改项目文件的这一部分(如果修改了,我不知道具体时间),因为您在 UI 中选择了构建配置,并且它使用那个。但是,由于 Expression Blend(使用版本 4)不允许您选择构建配置,因此它只会选择最上面的一个。结果是您收到“无效的 XAML”,并且所有引用旁边都有刘海 (!)。
在我看来(并且知道我的分析可能有缺陷),这是 Expression Blend 的缺陷。它不仅应该能够使用 studio 可以使用的任何构建配置,而且您还应该能够选择它。
After a wasted day tracking this down I found this:
Open up the .proj file in a text editor and take a look at the very top of the file, there will be a list of PropertyGroup sections in the XML. Take a look at the first one, if it says x86 or anything other than AnyCPU, change it to say AnyCPU and save it.
should be:
Why? I'm not 100% sure, but it appears that Visual Studio doesn't modify this part of the project file (if it does, I don't know when exactly), since you choose your build configuration in the UI and it uses that instead. However, since Expression Blend (using version 4) doesn't allow you to choose your build configuration it just picks the top one. The result is that you get "Invalid XAML" and all of your references have bangs (!) next to them.
In my opinion (and knowing my analysis could be flawed) this is a deficiency in Expression Blend. Not only should it be able to use any build configuration that studio can, you should also be able to select it.