开发者

In C# (WPF) does databinding occur when the datachanges in the UI thread immediately?

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开发者_JAVA百科 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜