title: Base UserControl Class in Windows 8 XAML Metro App
body: <p>I'm working on a Metro app using XAML &amp; C#. I started this using WPF in Win7. I created a base class, inheriting from UserControl, then tried to put that in my XAML.</p>
  
  <p>In Windows 7, this worked great:</p>
  
  <pre><code>&lt;MyType:AnImplementation
   ...
   xmlns:MyType="clr-namespace:MyAppNamespace"
  /&gt;
  </code></pre>
  
  <p>I tried the same thing in Win8, but unfortunately, I get errors - </p>
  
  <pre><code>&lt;MyType:AnImplementation
   ...
   xmlns:MyType="using:MyAppNamespace"
  /&gt;
  </code></pre>
  
  <p>now produces this:
  CompileXaml task failed unexpectedly. Then a null reference exception.</p>
  
  <p>I'm no WPF whiz, so I may be doing this completely wrong - I just recently started getting into it, but I'm having trouble isolating this issue. Is this some sort of chicken/egg problem, or is there a different way to build custom user controls in Win8 XAML?</p>
  
  <p><strong>edit</strong>: I thought it may be helpful to be more clear. I'm not having trouble creating user controls, I'm having trouble creating usercontrols that are of my own base type, which inherits from <code>UserControl</code>. For instance:</p>
  
  <p>A base class, we'll call MyBaseType, which inherits from UserControl and has some virtual methods:</p>
  
  <pre><code>public class MyBaseType : UserControl
  {
      public MyBaseType() : base() {}
  }
  </code></pre>
  
  <p>A new usercontrol, called ActionTile:</p>
  
  <pre><code>public partial class ActionTile : MyBaseType {}
  </code></pre>
  
  <p>When I put this in my XAML:</p>
  
  <pre><code>&lt;myType:MyBaseType
      ... (other XAML imports)
      xmlns:myType="using:MyNamespace"/&gt;
  </code></pre>
  
  <p>The compiler blows up.</p>
  
  <p>If you want to replicate, create a base class inheriting from <code>UserControl</code>, then implement a control inheriting from the base class and try to create a new UserControl of that new type. As I said, works fine in WPF on Windows 7.</p>