Problem trying to open a WPF project in Expression-Blend 4 that was created in Visual Studio 2010

I am creating my WPF project in VS 2010. After I finished working with the functional GUI, I wanted to edit the template of my controls in Blend 4. But when I open the project in Blend, in DesignMode, it tells me


Invalid XAML


In the Result window, he wrote:


[ControlName] is not supported in a Windows Presentation Foundation (WPF) project


Where [ControlName] is the list of default controls that I used in my project (for example, Window, DockPanel, etc.)

What to do to avoid these problems and be able to edit WPF forms in DesignMode expressions-Blend4?

EDIT:

Possible workaround.

After some comparison of empty projects (* .csproj file), which was created by Blend and Studio , I found that VisualStudio creates it with the following 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 the project as expected.

+6
source share
2 answers

I saw this message only once. After comparing the new solution file with the one that is not loading, I found that Blend requires the AnyCPU platform / configuration that needs to be defined.

If this does not work, make sure that you have all the necessary assemblies for the WPF project: PresentationCore , PresentationFramework and WindowsBase .

NTN

+11
source

After I skipped this day, I found this:

Open the .proj file in a text editor and look at the very top of the file, there will be a list of sections of the PropertyGroup in XML. Take a look at the first, if it says x86 or nothing but 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> 

it 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 am not 100% sure, but it seems that Visual Studio does not modify this part of the project file (if so, I don’t know when exactly), since you choose the assembly configuration in the user interface and use it instead. However, since Expression Blend (using version 4) does not allow you to choose the assembly configuration, it simply selects the top one. As a result, you get "Invalid XAML", and all your links have next to them (!).

In my opinion (and knowing my analysis might be wrong), this is a flaw in Expression Blend. Not only can he use any build configuration that the studio can use, you can also choose one.

+1
source

Source: https://habr.com/ru/post/893264/


All Articles