XAML Designer "cannot find type" when converters are in UserControl.Resources

I have a WPF UserControl with referenced link converters:

<UserControl x:Class="MyControl" x:Name="MyControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TheMainNamespaceOfThisAssembly"> <UserControl.Resources> <local:ConfidenceColorConverter x:Key="ConfidenceColorConverter"/> </UserControl.Resources> 

Then I use the binding converter later. I see a user control in my design window. Then I compile and then put this control in the main window. I run it and it works. However, I would still like to use the constructor in the main window, which breaks:

Failed to create an instance of type MyControl.

So, I learned how to debug a constructor ; when I do this, I get a XamlParseException:

Cannot find type "TheMainNamespaceOfThisAssembly.ConfidenceColorConverter". The assembly used at compilation may differ from that used at boot, but the type is missing. Error in markup file ...

If you delete the links to the converters, my user control will be displayed in the designer in the main window. Any ideas how to fix my converter links so that they don't break the constructor?

Failed to figure out if the article Troubleshooting WPF Designer Boot Errors is applicable.

+4
source share
2 answers

After talking with others, the VS2008 developer has many problems that prevent its use in many situations. We gave up.

Update. It seems that some of them, especially Joel Cochran, use the Expression Blend design design with great success, as long as you obey his four principles of MVVM in the development of XAML.

+1
source

Could you try to reproduce the problem on a clean new project, and not on editing an existing one? You cannot have

 <UserControl x:Class="MyControl" x:Name="MyControl"... 

since you need to add a namespace to "x: class" and change the value of "x: Name" so that it differs from the class name. The designer works great when I create a clean project, when you describe and correct such errors. You can omit some details from the question, which, in your opinion, is unimportant, but these details may matter.

+1
source

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


All Articles