New WPF Custom Control Library Name does not exist in Namespace

This can also happens if you don't write the default style for CustomControl in generic.xaml. It generates something like this in generic.xaml:

<Style TargetType="{x:Type local:MyCustomControl}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:MyCustomControl}">
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

you can find this piece of code and change or remove it.


This is an IntelliSense error, not a build error, so it should not affect building the project. To resolve this error, either

  • build the project, or
  • edit the document (e.g. by removing a > from a tag, then adding it back).

When you open the document, the XAML designer loads in the background to provide IntelliSense information. It loads information for unbuilt types (i.e., types defined in the current Solution but which have not yet been built into an assembly) asynchronously, and often this process completes after the designer has completed the initial parse of the document.

Building the project will cause the unbuilt types to be built (thus resolving the issue), and making a material edit to the document will cause the designer to reparse the document with the newly available type information (ideally, the document should be reparsed when the unbuilt type information becomes available).


According to the answer of James McNellis, in my case I had to comment out the XAML-section causing the error (since the error did not allow to rebuild), then CLOSE the file itself, so its not open in VS, then I could make a successful build. Then I uncommented the XAML-section and VS was able to locate the local classes... In case, someone would stumble on this. Visual Studio 2012 Express for Windows Desktop... BR,

Daniel