How can I force a textbox change to enable my command in WPF? -


I have found a text box in a WPF window which is bound to a string property in my view modal. I have a button which is bound for a command, the default button in the button window, so that the command runs when the login is entered.

If I type in the text box, press enter, all the expected work.

However, this textbox is also a place that receives a barcode from a barcode scanner, which adds a code to the keyboard buffer. Enter barcode scanner "type" barcode and press (it is working).

The problem is, if the text box is empty, the barcode scanner fills it but has not been entered because the order is yet to be available, if the text box starts with something in it, then Everything works when a barcode scan is done.

I am compelled:

  text = "{binding barcode, updates source trigger = property changed}"  

property of ViewModel Notify via INotifyPropertyChanged and I also tried to become an order to try to run CommandManager.InvalidateRequerySuggested () is available, but no avail.

commandmanager.invalitrequery indicates should work; However, I think it is also asynchronous, so if the scanner sends the keystrokes very fast, before WPF can get an opportunity to update everything. Try to stop the entry and delay it in a little while, maybe with the dispatcher.

or commandmanager with a dispatcher. Unexpected recommended open. Have fun with high priority (send me guess that is the highest).

EDIT: Also, the default behavior is to update the textbox's binding only to the LostFocus, I think you have changed the property by changing it? Never mind, it looked at your question.


Comments