Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

Could you please try to reproduce the problem on a clean new project rather than editing your existing one? You cannot have

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

as you would need to add a namespace to "x:class" and change "x:Name" value to be different from class name. The designer works fine when I create a clean project as you describe and fix this sort of errors. You might be omitting some details from the question you think are unimportant, but those details can make all the difference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top