TextBox Binding TwoWay 在焦点丢失之前不会更新 WP7 [英] TextBox Binding TwoWay Doesn't Update Until Focus Lost WP7

查看:14
本文介绍了TextBox Binding TwoWay 在焦点丢失之前不会更新 WP7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含一些用于数据输入的文本框.文本框的绑定设置为TwoWay.我的视图模型中的数据只有在文本框失去焦点时才会更新.如果我单击一个按钮,例如保存,并且文本框仍然具有焦点,则在保存事件的视图模型中,文本框中的更改不会更改.

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?

推荐答案

您可以使用 WP7 的 Prism 库 用于在文本更改而不是失去焦点时更新绑定值.

You can use the UpdateTextBindingOnPropertyChanged behavior from the Prism Library for WP7 to update the bound value when the text changes instead of on lost focus.

这篇关于TextBox Binding TwoWay 在焦点丢失之前不会更新 WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆