How to solve XAML designer error: The document contains errors that must be fixed before the designer can be loaded

匿名 (未验证) 提交于 2019-12-03 00:48:01

问题:

I have a XAML file that references custom controls defined into another assembly. It compiles and works perfectly at runtime, but the XAML designer is choking and does not show the design content.

<Window x:Class="MyProgram.AboutWindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:copy="clr-namespace:MyCompany.Common.CopyProtection;assembly=Common"     Title="About Box" Height="400" Width="400" SizeToContent="Height">     <copy:RegistrationPanel  /> </Window> 

The class MyCompany.Common.CopyProtection is loacted inside the Common assembly, which is in the references for this project. The class is public, and freshly built.

I am using Visual Studio Express 2008 with .NET 3.5 SP1. Here are the errors:

Problem Loading

The document contains errors that must be fixed before the designer can be loaded. Reload the designer after you have fixed the errors.

Error 1 The type 'copy:RegistrationPanel' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Error 2 Assembly 'Common' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built.

Anybody knows how to solve those errors so I can start using the designer again. The designer is pratical to select XAML elements and quicly jump into XAML code.

回答1:

The WPF designer included with VS2008 is inadequate for all but the simplest of tasks. My advice is don't use it and instead use something Blend if you can, or perhaps Kaxaml for smaller XAML tests.

I turn the XAML editor off completely by mapping the .xaml extension to the standard XML Editor. This improves load times, and avoids all these annoying "errors" spewed out by the XAML designer.



回答2:

I had a problem with this where I had styles as StaticResource, after changing these into DynamicResource it worked well for me.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!