I've got a textbox in a WPF window that's bound to a string proprty in my ViewModel. I also have a button that is bound to a command. The button is the default button in the window so that when enter is pressed, the command runs. The command is only enabled when the textbox is not empty.
If I type into the textbox, then hit enter, all works as expected.
However, this textbox is also the place that receives barcodes from a barcode scanner that adds codes to the keyboard buffer. The barcode scanner "types" the barcode and presses Enter (this is working).
The problem is, if the textbox is empty, the barcode scanner fills it but the Enter is not captured becaue the command has yet to become available. If the textbox starts with something in it everything works when the barcode is scanned.
My binding is:
Text="{Binding Barcode,UpdateSourceTrigger=PropertyChanged}"
The property of the ViewModel notifies via INotifyPropertyChanged
and I also tried running CommandManager.InvalidateRequerySuggested()
to try to get the command to become available but to no avail.