title: WPF custom window does not apply its generic template at design time
body: <p>I have created a simple WPF custom control which inherits from Window, so that later I am able to override it's chrome and reuse it across my projects. The control is contained in its own project along with a <strong>generic.xaml</strong> file (in the <strong>Themes</strong> directory). The style for the control simply sets a red background. Within a second project (same solution) I then use the control as the base class of a new WPF window. When I now compile the project and have it run, it shows my (custom-)window with the desired red background.</p>
  
  <p>My question is now: how do I get the <strong>WPF designer</strong> to show the generic style (in this case the red background) at design time?</p>
  
  <p>When I do the same with, say, a button then the generic style is applied at design time automatically. But any default style of a control inheriting from Window will only show at runtime. What am I missing?</p>
  
  <p>control code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CustomControl1 : Window
  {
      static CustomControl1()
      {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1)));
      }
  }
  </code></pre>
  
  <p>generic.xaml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Style TargetType="{x:Type local:CustomControl1}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type local:CustomControl1}"&gt;
                  &lt;Border Background="Red"/&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The XAML of the test window in the second project where I use the control:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;snh:CustomControl1 x:Class="WpfDockWindow.TestWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:snh="clr-namespace:SnH.WpfControls;assembly=SnH.WpfControls"
      Title="TestWindow" Height="300" Width="300"&gt;
  &lt;Grid&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And for the records, I use VS2013 and the projects are compiled with framework 4.5.1.</p>
  
  <p>Thx, 
    Ben</p>