title: WPF TextBox not accepting Input when in ElementHost in Window Forms
body: <p>We are developing a UI Control in WPF to be consumed within an existing Windows Forms / MFC application engine (Rhino 3D).</p>
  
  <p>The application engine exposes the ability create a "Dockbar" which essentially lets you put Windows Forms controls inside a child window which can dock to the Engines Interface.</p>
  
  <p>I am attempting to put a simple WPF TextBox inside an ElementHost control, which is added to the Dockbar.  This appears to work fine at first glance; but after attempting to type into the TextBox only certain sequences actually show up in the TextBox.  The <strong>DELETE</strong>, <strong>BACKSPACE</strong>, <strong>COPY</strong>, <strong>PASTE</strong>, and <strong>SELECTING TEXT</strong> work.  If you type A-Z, 1-9, etc. those keys do not show up.</p>
  
  <p>I have SCOURED the net, and have heard about the <strong><code>ElementHost.EnableModelessKeyboardInterop()</code></strong> but this only applies to WPF Windows being created from the form.  I am only creating WPF UserControls and hosting them in the ElementHost control.</p>
  
  <p>I saw a post which talked about the Dispatcher.Run(), and it sort of works but breaks the rest of the form:</p>
  
  <pre><code>System.Windows.Threading.Dispatcher.Run();
  </code></pre>
  
  <p>The <strong>PreviewKeyUp</strong>, <strong>PreviewKeyDown</strong>, <strong>KeyUp</strong>, and <strong>KeyDown</strong> events all fire on the TextBox, but alas no text shows up in the TextBox.</p>
  
  <p>I don't know much about Windows Messages, but using WinSpector I noticed that no WM_GETTEXT messages were coming from the TextBox (if they even should be I don't know).</p>
  
  <p>I also create a new Windows Forms project and did the same thing in there and it works fine, so it must be an issue with how the windows are created and docked within the Rhino 3D engine.</p>
  
  <p>Here is the sample code which doesn't work:</p>
  
  <pre><code>ElementHost el = new ElementHost();
  System.Windows.Controls.TextBox t = new System.Windows.Controls.TextBox();
  t.Width = 100;
  t.Text = "TEST";
  el.Child = t;
  panel1.Controls.Add(el);
  </code></pre>