7

A WPF form that I launch from a WinForms window shows up with all textboxes as uneditable when it's launched as a modeless dialog. It works well when it's a modal window. I'm still able to type spaces or paste text. But regular typing doesn't work. I'm using 3.5 with SP1. Would anybody know how to resolve this?

aliensurfer
  • 1,600
  • 3
  • 17
  • 38
  • Yeah, can you post some code? Question is not much clear the way it is now to think about an answer. – picmate 涅 Apr 28 '11 at 12:32
  • If I do a wpfUI.Show() instead of wpfUI.ShowDialog(), the textboxes on my wpfUI window cannot be typed into. The code can't get any simpler than that. – aliensurfer Apr 28 '11 at 12:36

1 Answers1

10

You need to make sure to call ElementHost.EnableModelessKeyboardInterop for your WPF Window. This hooks up the WPF message loop to allow keyboard input.

CodeNaked
  • 40,753
  • 6
  • 122
  • 148
  • 2
    I've got a weird issue now. I am opening my WPF UI from an MS Excel as an add-in too. The EnableModelessKeyboardInterop doesn't work there. Whenever I try to edit my WPF textbox, the focus shifts to Excel and the keyboard input is generated on Excel. Any ideas on how to fix this? This is what I found for it, but I hope this is not the only solution: http://blogs.msdn.com/b/andreww/archive/2009/02/24/message-hooks-in-add-ins.aspx – aliensurfer May 03 '11 at 03:02
  • @Prakash - Sorry, I don't have any experience with Excel plugins. You may want to as this as another question. – CodeNaked May 03 '11 at 11:29