title: Starting a custom window in wpf from code behind does not draw it's content
body: <p>In my tests, I've created a simple class like this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  
  namespace Test
  {
      public class MyCustomWindow: Window
      {
  
      }
  }
  </code></pre>
  
  <p>This class is compiled into a dll. 
  In another project, I tried to use this custom window, like this:</p>
  
  <pre><code>&lt;Custom:MyCustomWindow x:Class="MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Custom="clr-namespace:Test;assembly=Test"
      Title="MainWindow" Height="600" Width="1210" WindowState="Maximized" &gt;
  
     &lt;Grid Background="Blue"&gt;
         &lt;Button Content="Button" HorizontalAlignment="Left" Margin="457,212,0,0" VerticalAlignment="Top" Width="75"/&gt; 
     &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>This thing compiles with no errors, and works great when the custom window is opened by the "StartupUri" in the App.xaml file (that defines the first window loaded).</p>
  
  <p>However, if I set other window to load in the StartupUri, and:</p>
  
  <pre><code>MainWindow m = new MainWindow();
  m.Activate();
  m.Show();
  this.Close();
  </code></pre>
  
  <p>The CustomWindow will open, but without any content, without button and without the blue grid - and even without the title.</p>
  
  <p>Any workaround? And what I need to do to open a Window with the same behavior of the StartupUri?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I've noticed that the MainWindow (or any window derived from MyCustomWindow) simply cannot have the method InitializeComponent() in the constructor, because it does not exist in the context. Strangely, when using StartupUri, the contents are loaded normally without this.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>I think that the problem is occurring because I can't put the InitializeComponent() method in the MyCustomWindow. This explains why the MainWindow can be loaded normally into the StartupUri: it's loading directly from the xaml file, so it's parsing the content without the need of the InitializeComponent. </p>
  
  <p>I starting to think about implement the IComponentConnector interface, but I have no idea how to do this.</p>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>The code-behind of the file MainWindow.xaml.cs is:</p>
  
  <pre><code>using Test;
  
  namespace TestingCustomWindow
  {
      public partial class MainWindow : MyCustomWindow
      {
          public MainWindow()
          {
                // Cannot use InitializeComponent here
          }
      }
  }
  </code></pre>