title: Programmatically sending keys to a textbox does not update its binding
body: <p>I am using a ThirdParty keyboard control (DotNetBar from DevComponents, link <a href="http://www.devcomponents.com/dotnetbar/TouchKeyboardControl.aspx" rel="nofollow">here</a>) within a WPF desktop application to enter text within a TextBox control. The application is developped on Windows 8 and .NET 4.5.</p>
  
  <p><strong>NOTE:</strong> The Windows Tablet Tip was tried, but it has many limitations which makes it difficult to use.</p>
  
  <p>The keyboard being a WindowsForms control, it is put within a WindowsFormsHost. 
  Since the WindowsForms SendKeys method used by this keyboard will not work well in WPF (as mentionned in many articles on SO), I am programmatically sending the keys to the textbox using the InputManager, like so:</p>
  
  <pre><code>    private void _keyboardControl_SendingKey(object sender, KeyboardKeyCancelEventArgs e)
      {
          // to prevent SendKeys to happen.
          e.Cancel = true;
  
          if (string.IsNullOrEmpty(e.Key))
          {
              return;
          }
  
          // A special key is a key like "Enter", "Backspace", "Left arrow", ...
          if (IsSpecialKey(e.Key))
          {
              var keyEventArgs = new KeyEventArgs(
                 System.Windows.Input.Keyboard.PrimaryDevice,
                  System.Windows.Input.Keyboard.PrimaryDevice.ActiveSource,
                 0,
                 GetKeyValueFromStringCode(e.Key)) { RoutedEvent = Keyboard.KeyDownEvent };
              InputManager.Current.ProcessInput(keyEventArgs);
          }
          // "Normal" keys, like a, b, C, (, 1, ....
          else
          {
             var textCompositionEventArgs = new TextCompositionEventArgs(
             System.Windows.Input.Keyboard.PrimaryDevice,
              new TextComposition(InputManager.Current,
                  System.Windows.Input.Keyboard.FocusedElement,
                  e.Key)) { RoutedEvent = Keyboard.TextInputEvent };
  
              InputManager.Current.ProcessInput(textCompositionEventArgs);
          }
      }
  </code></pre>
  
  <p>This effectively puts the right keys into the target WPF textbox which has the focus prior to showing the ThirdParty keyboard.
  The textbox Text property has binding to a ViewModel property. The issue is that the updates made to the textbox are not being propagated through the binding when keys are entered programmatically.
  If I use my own physical keyboard to type within the same textbox instead, the binding is correctly updated.</p>
  
  <p>Any guidance on this would be greatly appreciated. It took a while to get here, it would be too bad if what I'm trying is not possible. Thanks!</p>