title: Why is my WPF hosted WinForm blank?
body: <p>I have used the code from <a href="http://shevaspace.blogspot.com/2007/02/how-to-host-top-level-hwnds-in-wpf.html">this blog</a>, as below but abridged, and I see the WinForm inside my main window, but the sample text I placed on it in a label is not visible.</p>
  
  <pre><code>[System.Windows.Markup.ContentProperty("Child")]
  public class WinFormsHost : HwndHost
  {
    public WinFormsHost()
    {
      var form = new ChildForm();
      Child = form;
    }
    private System.Windows.Forms.Form child;
    public event EventHandler&lt;ChildChangedEventArgs&gt; ChildChanged;
    public System.Windows.Forms.Form Child
    {
      get { return child; }
      set
      {
        HwndSource ps = PresentationSource.FromVisual(this) as HwndSource;
        if (ps != null &amp;&amp; ps.Handle != IntPtr.Zero)
        {
          throw new InvalidOperationException("Cannot set the Child property after the layout is done.");
        }
        Form oldChild = child;
        child = value;
        OnChildChanged(oldChild);
      }
    }
  
    private void CheckChildValidity()
    {
      if (child == null || child.Handle == IntPtr.Zero)
      {
        throw new ArgumentNullException("child form cannot be null");
      }
    }
  
    public Boolean ShowCaption
    {
      get
      {
        CheckChildValidity();
        return (GetWindowStyle(Child.Handle) &amp; WindowStyles.WS_BORDER) == WindowStyles.WS_CAPTION;
      }
      set
      {
        if (child == null)
        {
          this.ChildChanged += delegate
          {
            if (value)
            {
              SetWindowStyle(Child.Handle, GetWindowStyle(Child.Handle) | WindowStyles.WS_CAPTION);
            }
            else
            {
              SetWindowStyle(Child.Handle, GetWindowStyle(Child.Handle) &amp; ~WindowStyles.WS_CAPTION);
            }
          };
        }
        else
        {
          if (value)
          {
            SetWindowStyle(Child.Handle, GetWindowStyle(Child.Handle) | WindowStyles.WS_CAPTION);
          }
          else
          {
            SetWindowStyle(Child.Handle, GetWindowStyle(Child.Handle) &amp; ~WindowStyles.WS_CAPTION);
          }
        }
      }
    }
  
    protected override HandleRef BuildWindowCore(HandleRef hwndParent)
    {
      CheckChildValidity();
      HandleRef childHwnd = new HandleRef(Child, child.Handle);
      SetWindowStyle(childHwnd.Handle, WindowStyles.WS_CHILD | GetWindowStyle(childHwnd.Handle));
      WindowsFormsHost.EnableWindowsFormsInterop();
      System.Windows.Forms.Application.EnableVisualStyles();
      SetParent(childHwnd.Handle, hwndParent.Handle);
      return childHwnd; 
    }
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>&lt;Window x:Class="WinFormsHost" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 
     xmlns:cc="clr-namespace:XTime.Shell.WinformsHost" 
     Title="Hosting Form In WPF"&gt;
    &lt;cc:WinFormsHost ShowCaption="False"&gt;
      &lt;wf:Form/&gt;
    &lt;/cc:WinFormsHost&gt;
  &lt;/Window&gt;
  </code></pre>