title: WPF UserControl with generic code-behind
body: <p>I have this code behind:</p>
  
  <p>CustomUserControl.xaml.cs</p>
  
  <pre><code>namespace MyProject
  {
      public partial class CustomUserControl&lt;T&gt; : UserControl
      {
          ...
      }
  }
  </code></pre>
  
  <p>and this xaml:</p>
  
  <p>CustomUserControl.xaml</p>
  
  <pre><code>&lt;UserControl x:Class="MyProject.CustomUserControl"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:sys="clr-namespace:System;assembly=mscorlib"&gt;
  &lt;Grid&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>It doesn't work since the x:Class="MyProject.CustomUserControl" doesn't match the code-behind's generic class definition. Is there some way to make this work?</p>