tags:

views:

54

answers:

1

I'm creating an application and I've been under the assumption that when a control is bound to a member in the view-model (i.e. a TextBox to a string field) the string is updated whenever the user changes the information in the textbox and no later.

But what I've found is that the string is updated when the textbox is changed AND when the user clicks\tabs out of the textbox.

(I'm using the Caliburn.Micro framework if that matters.)

Can someone explain which is correct and how to make it so that a change is immediately reflected?

+5  A: 

This is not a WPF issue... it totally lies with the controls.

But what I've found is that the string is updated when the textbox is changed AND when the user clicks\tabs out of the textbox.

This is specific textbox to reduce the amounts of set operations and avoid setting incomplete data.

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c3ae2677-7cc9-4bb3-9cce-4e7c0eeff6f0 has a solution - basically update source trigger is set to property changed. If you do that, though, you get a lot more invalid data into the model, like for example when people enter an invocie number all the partials will be going to the model.

http://msdn.microsoft.com/en-us/library/system.windows.data.binding.updatesourcetrigger.aspx has a nice explanation - klike it says, normal trigger is PropertyChanged, while the text property defaults to LostFocus.

TomTom
Thanks for the answer I'll definitely look into the link. As for bad data, the view-model is actually doing the input validation and won't save anything into the model unless everything passes.
Scifiballer24
Sure. it just is a lot less validation if you only deal with "finished input" and do not get the "on the way" updates ;)
TomTom