Search code examples
wpfxamluser-controlsdesignercider

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


I have a WPF UserControl with binding converters referenced like this:

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

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

Could not create an instance of type 'MyControl'.

So I learned how to debug the designer; when I do, I get an XamlParseException:

Cannot find type 'TheMainNamespaceOfThisAssembly.ConfidenceColorConverter'. The assembly used when compiling might be different than that used when loading and the type is missing. Error in markup file...

If remove the references to the converters, my user control displays well in the designer on the main window. Any ideas how to fix my references to the converters so that they won't break the designer?

Couldn't understand if the article Troubleshooting WPF Designer Load Failures applies or not.


Solution

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

    Update: It seems like some, especially Joel Cochran, are using the Expression Blend design view with more success, as long as you obey his four principles of MVVM in XAML development.