TextBox Binding TwoWay Doesn't Update Until Fo

2019-01-16 23:08发布

I have a page with some text boxes for data input. The binding of the text box is set to TwoWay. The data in my view model only gets updated if the text box loses focus. If I click a button, such as save, and the text box still has the focus, the changes in the text box aren't changed in my view model on the save event.

Is there a way to have the binding save the value of the text box before it loses focus? Or do I need to do something in the save event?

8条回答
Explosion°爆炸
2楼-- · 2019-01-16 23:57

I haven't tried @Praetorian's answer so if that works well then do that - otherwise, use both the KeyUp AND TextChanged events to update the Binding source.

查看更多
姐就是有狂的资本
3楼-- · 2019-01-17 00:02

try to set UpdateSourceTrigger property to 'PropertyChanged'

like this

Property="{Binding PropertyBinding, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
查看更多
登录 后发表回答