title: XAML error using a class derived from UserControl as a base
body: <p>I am using WPF and I'm trying to make a class inherit from <code>UserControl</code> and use that class as a base class for other classes. I've read numerous articles on how to do this (such as <a href="https://stackoverflow.com/a/887527/726361">this one</a> which has over 50 upvotes), but they all say the same thing and none of them work.</p>
  <p>I have this code:</p>
  <pre><code>namespace MyNamespace {
      // handwritten
      public class BaseControl : UserControl { }
  
      // generated by the IDE
      public partial class XAMLControl1 : UserControl {
          ...
      }
  }
  </code></pre>
  <p>Now, I change that line to</p>
  <pre><code>public partial class XAMLControl1 : BaseControl {
  </code></pre>
  <p>And in the XAML, I change it from</p>
  <pre><code>&lt;UserControl x:Class=&quot;MyNamespace.XAMLControl1&quot; ...&gt;
      ...
  &lt;/UserControl&gt;
  </code></pre>
  <p>To</p>
  <pre><code>&lt;my:BaseControl x:Class=&quot;MyNamespace.XAMLControl1&quot;
                  xmlns:my=&quot;clr-namespace:MyNamespace&quot; ...&gt;
      ...
  &lt;/my:BaseControl&gt;
  </code></pre>
  <p>The <code>my:BaseControl</code> part is underlined in squiggly blue, so when I hover it, IntelliSense says</p>
  <blockquote>
  <p>The name &quot;<code>BaseControl</code>&quot; does not exist in the namespace &quot;<code>clr-namespace:MyNamespace</code>&quot;.</p>
  </blockquote>
  <p>And the compiler gives me the strange errors</p>
  <blockquote>
  <ol>
  <li><p>Closing tag for element '&lt;m&gt;' was not found.</p>
  </li>
  <li><p>The type '<code>m</code>' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.</p>
  </li>
  <li><p>The name &quot;<code>BaseControl</code>&quot; does not exist in the namespace &quot;<code>clr-namespace:MyNamespace</code>&quot;.</p>
  </li>
  </ol>
  </blockquote>
  <p>Yes, that's &quot;The type '<code>m</code>' was not found&quot;. I don't see where I'm trying to use a type named <code>m</code> anywhere. I think this is an unrelated compiler bug, but I thought I'd mention it. And also I'm definitely sure the type <code>BaseControl</code> does exist in the namespace <code>MyNamespace</code>. Intellisense comes up with no suggestions after I type the <code>my:</code>.</p>
  <p>What can I do to fix this problem? I am using Visual Studio 2012 Express for Windows Desktop (7).</p>