开发者

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


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 开发者_Python百科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.


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, and WindowsBase.

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. Take a look at the first one, if it says x86 or anything other than AnyCPU, change it to say AnyCPU and save it.

<?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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜