Tech Off Post

Single Post Permalink

View Thread: Strange WPF Textbox Problem
  • User profile image
    KAE

    http://forums.microsoft.com/msdn/showpost.aspx?postid=1104593&siteid=1

    "Proper input interop with a non-WPF host (such as WinForms) requires some cooperation between the host and the WPF input system. The topic Sharing Message Loops Between Win32 and WPF  in the SDK explains this well. At a minimum, you have to call ComponentDispatcher.RaiseThreadMessage() from the host’s message loop. In your setup, the easiest way to make this happen is to use code like this:

       Window w = new Window1();

       System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(w);

       w.Show();

     

    ElementHost.EnableModelessKeyboardInterop() essentially registers an input hook with the WinForms Application object (which normally runs the message loop) and calls ComponentDispatcher.RaiseThreadMessage()."