Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding in TextBoxes do not work

Tags:

binding

wpf

I created a simple TextBox with a binding in a pure WPF-Window

<TextBox Name="MyTextBox"
         Focusable="True" Width="150"
         Text="{Binding MyText, UpdateSourceTrigger=PropertyChanged}"</TextBox>

My problem is, that underlaying string property 'MyText' is not updated in any case. If I type a space character, the property is updated. If I paste text through the clipboard into the TextBox, the property MyText is updated. But if I type in any other character, nothing happens. I registered a event handler for TextChanged for debug purposes. The event only occures for the space character and the paste operation, but for no other characters.

Some words about my enviroment: The WPF-Window can be stripped down to just this TextBox. I open this Window from inside a DLL. The complete project was targeted to .Net2, now, due to WPF, to Framework 3.5. I don't know how to make this more simple to find the problem.

like image 741
Jens Avatar asked Mar 11 '11 07:03

Jens


1 Answers

You mentioned Framework 2.0. If your application bases on Windows Forms, you should keep in mind some interop topics. Have you tried the following before opening the window:

System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(YourWindowObject)

Otherwise try to open your window from a WPF-Application.

like image 137
Markus Avatar answered Sep 29 '22 01:09

Markus