TextBox绑定TwoWay不更新直到焦点丢失WP7 [英] TextBox Binding TwoWay Doesn't Update Until Focus Lost WP7

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

问题描述

我有一个页面,其中有一些文本框用于输入数据。文本框的绑定设置为 TwoWay 。如果文本框失去焦点,我的视图模型中的数据将被更新。如果我点击一个按钮,如保存,文本框仍然具有焦点,文本框中的更改在保存事件的视图模型中不会更改。



有没有办法让绑定保存文本框的值失去焦点?还是需要在保存事件中做一些事情?

解决方案

您可以使用 http://compositewpf.codeplex.com =noreferrer> WP7的Prism库更新文本更改而不是丢失焦点时的绑定值。


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?

解决方案

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绑定TwoWay不更新直到焦点丢失WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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