在WPF中对菜单进行操作时,为什么TextBox不会失去焦点? [英] Why a TextBox does not lose the focus when acting over a menu in WPF?

查看:242
本文介绍了在WPF中对菜单进行操作时,为什么TextBox不会失去焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在与ViewModel绑定的TextBox上编辑文本,然后单击主应用程序菜单(以保存数据),则ViewModel不会使用新数据进行更新,因为TextBox不会以某种方式松散焦点,然后不更新数据。为什么TextBox不会失去焦点,我该如何解决呢?

if I edit the text on a TextBox that is binded with the ViewModel and then I click at the main application menu (to save the data) the ViewModel does not get updated with the new data because somehow the TextBox does not loose the focus and then the data is not updated. Why the TextBox does not lose the focus and how should I fix that?

推荐答案

如果问题是数据绑定更新而不是焦点在文本框绑定中使用UpdateSourceTrigger = PropertyChanged。

If the problem is databinding updation and not the focus use UpdateSourceTrigger="PropertyChanged" in the textbox binding.

这篇关于在WPF中对菜单进行操作时,为什么TextBox不会失去焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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