Live binding property change for textbox [duplicat

2019-06-26 00:33发布

问题:

This question already has an answer here:

  • TextBox and default Button binding does update too late 3 answers

I have a TextBox control on my form that is bound to a property in my view model. The current behaviour works in a way that the view model will only get notified that the text in the TextBox was modified after the control loses focus.

How can I inform my view model whenever the TextBox changes state in real time? This is attached to a property in my view model that determines if the save button is enabled. So if I type one letter into this TextBox right away my save button should be enabled without having to lose focus.

回答1:

Change UpdateSourceTrigger on the binding to PropertyChanged.