jbltx
jbltx

Reputation: 1315

WPF - CustomControl does not exist in the namespace

I have an issue when I create a new Custom Control in VS2015. Indeed, it generates a Themes/Generic.xaml file containing the error

"The name CustomControl does not exist in the namespace MyNamespace".

Of course, the custom control is located in the namespace MyNamespace and in the xaml file the local variable is well defined :

xmlns:local="clr-namespace:MyNamespace"

After some investigation, it appears it's a well-known bug with IntelliSense, and a simple restart should fix the problem, but it doesn't.

Related question

I tried

The error still there.

I didn't touch any line code generated by the IDE for the CustomControl, so maybe I missed something ?

using System.Windows;
using System.Windows.Controls;

namespace MyNamespace
{
    public class CustomControl : Control
    {
        static CustomControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl), new FrameworkPropertyMetadata(typeof(CustomControl)));
        }
    }
}

Thank you.

Upvotes: 1

Views: 1466

Answers (1)

jbltx
jbltx

Reputation: 1315

I finally found a workaround, it seems to be a problem related to CPU target. i was building for x64 but if I choose "Any CPU" and "Prefer 32bits", the Designer is able to find all members in namespaces. Maybe this occurs because Visual Studio is a 32bits application ? Thank you again.

Upvotes: 0

Related Questions