Posted By: jh71283 | Sep 4th, 2007 @ 9:57 AM
page 1 of 1
Comments: 4 | Views: 2042
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
    Hello All.

I Have a WPF Textbox on a window.

It receives keydown events, but it is not possible to change the text in the textbox.

 The Space, Backspace and delete keys work to change text that is already there, but none of the letters work( even though, as I said, the keydown events are registering ok)

I suspect, although I don't know why, that the events are being intercepted somewhere along the line, but I am not sure how I would go about finding out where exactly.


Can anybody give me a nudge in the right direction?
KAE
KAE
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()."

You are a rock star! I can't believe I missed this until now. I have 3-4 Wpf windows that I developed outside of my WinForms project and then moved into the project. I just spotted this problem after 2 months and spent a sleepless night troubleshooting to no avail.
You have saved me much aggravation!
Thanks much

Thanks, KAE! I was Google-ing this issue for quite a while. I knew I should have searched for "Strange WPF Textbox Problem" Smiley

page 1 of 1
Comments: 4 | Views: 2042
Microsoft Communities