简体   繁体   English

尝试在 Visual Studio 2010 中创建的 Expression-Blend 4 中打开 WPF 项目时出现问题

[英]Trouble when trying to open WPF project in Expression-Blend 4, which was created in Visual Studio 2010

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我在 VS 2010 中创建了我的 WPF 项目。在我完成功能 GUI 的工作后,我想在 Blend 4 中编辑我的控件模板。但是当我在设计模式中的 Blend 中打开项目时,他告诉我


Invalid XAML XAML 无效


In Result window he wrote:在结果 window 中,他写道:


[ControlName] is not supported in a Windows Presentation Foundation (WPF) project Windows Presentation Foundation (WPF) 项目不支持 [ControlName]


Where [ControlName] is list of default controls, which I have used in my project (such as Window, DockPanel, etc.)其中 [ControlName] 是我在项目中使用的默认控件列表(例如 Window、DockPanel 等)

What to do to avoid this issues and be able to edit WPF forms at DesignMode of Expression-Blend4?如何避免此问题并能够在 Expression-Blend4 的 DesignMode 下编辑 WPF forms?

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:在比较了由BlendStudio创建的空项目(*.csproj 文件)之后,我发现VisualStudio使用下一行创建它:

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
 ...

while Blend uses the following lines:而 Blend 使用以下几行:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

So, if you change x86 to AnyCPU , Blend will open project as expected.因此,如果您将x86更改为AnyCPU ,Blend 将按预期打开项目。

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.在将新的解决方案文件与无法加载的解决方案文件进行比较后,我发现 Blend需要定义AnyCPU平台/配置。

If that does not work, ensure that you have all the required assemblies referenced for a WPF project: PresentationCore , PresentationFramework , and WindowsBase .如果这不起作用,请确保为 WPF 项目引用了所有必需的程序集: PresentationCorePresentationFrameworkWindowsBase

HTH,高温下,

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.在文本编辑器中打开 .proj 文件并查看文件的最顶部,将在 XML 中列出 PropertyGroup 部分。 Take a look at the first one, if it says x86 or anything other than AnyCPU, change it to say AnyCPU and save it.看第一个,如果是 x86 或者 AnyCPU 以外的任何东西,把它改成 AnyCPU 并保存。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>

should be:应该:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

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.我不是 100% 确定,但似乎 Visual Studio 不会修改项目文件的这一部分(如果是,我不知道确切的时间),因为您在 UI 中选择构建配置并且它使用相反。 However, since Expression Blend (using version 4) doesn't allow you to choose your build configuration it just picks the top one.但是,由于 Expression Blend(使用版本 4)不允许您选择构建配置,它只会选择最上面的配置。 The result is that you get "Invalid XAML" and all of your references have bangs (.) next to them.结果是您得到“无效的 XAML”,并且您的所有引用旁边都有刘海 (.)。

In my opinion (and knowing my analysis could be flawed) this is a deficiency in Expression Blend.在我看来(并且知道我的分析可能有缺陷)这是 Expression Blend 的一个缺陷。 Not only should it be able to use any build configuration that studio can, you should also be able to select it.它不仅应该能够使用工作室可以使用的任何构建配置,您还应该能够 select 它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM