5

I have a WPF project (creating dll). The text boxes that added, (or the listboxs) will only accept, COPY, PASTE, DELETE, and BACKSPACE.I do not know why the textboxs have this behavior. The system receives all of the events (KEYUP, KEYDOWN, PREVIEWKEYUP, PREVIEWKEYDOWN, but won't change the text if characters are typed.

The TEXTCHANGED event only fires for the Delete, Paste, etc.

The textbox is enable and NOT readonly.

Any help would be appreciated. thanks, talia.

4
  • Hi Talia - it's unclear from your question whether you have mysteriously acquired textboxes with this behaviour, and "cannot write in textbox wpf" is the problem, or you would like to create textboxes like this, and want some suggestions as to how. Please could you clarify? Commented Jul 25, 2010 at 7:33
  • I do not know why the textboxs have this behavior. i would like to write in side the textbox. Commented Jul 25, 2010 at 7:52
  • Could you please give an example of how are you actually creating them. Commented Jul 25, 2010 at 7:56
  • yes, just add it from the toolbox. <Textbox Higth="23" Margn="100,0,58,22" Name="textBox1" VerticalAlignment="Bottom" /> Commented Jul 25, 2010 at 8:38

3 Answers 3

12

adding this:

Window window1 = new Window(); 
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(window1); 
window1.Show(); 

should fix the bug.

also add a reference to WindowsFormsIntegration.

thanks everyone!

Sign up to request clarification or add additional context in comments.

2 Comments

You did not mention WinForms intergration was involved!
there is no integration with WinForms... this is wpf project. although in the solution there are other WinForms projects...
2

I had this same problem and then realised that I had handled the KeyDown event on the parent Window (and also set e.Handled to true). This in effect prevented any child controls from seeing KeyDown events.

Comments

0

I have had this situation before, my only solution was to create a new solution / project and copy the code across.

Quite weird!

5 Comments

I did try to do as you said, and and it did not help.still I have no idea what to do...
and if you create a new solution and empty project, do you still get the same?
I opened a new wpf Application and then its ok. but my project is wpf user control Lib. i should creat a dll. anyway creat a new solution and copy everyhing because have lots of projects in it. is there another way? thanks
This might be a long shot, try installing / reinstalling .net 3.5 sp1 - social.msdn.microsoft.com/forums/en-US/wpf/thread/…
I had .net 3.5 sp1 installed. I uninstalled and reinstalled it. It did not help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.