在将文本输入到 TextBox 时立即触发 TextChanged 事件 [英] Having TextChanged Event Fire Immediately as Text is Typed into TextBox

查看:96
本文介绍了在将文本输入到 TextBox 时立即触发 TextChanged 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有 TextChanged 事件的 wpf TextBox 上,它似乎仅在焦点从文本框移开时触发;但不是因为输入了单个字符.

On a wpf TextBox that has an TextChanged event, it seems to only fires when focus is taken away from the textbox; but not as individual characters are typed in.

是否有一个类似于 TextChanged 的事件在文本框中输入字符时立即触发,而不是在焦点改变时触发?

Is there an event similar to TextChanged that fires immediately when a character is typed into the textbox, rather than when focus changes?

推荐答案

您可以绑定 Text 属性并使用 UpdateSourceTrigger.

You can bind the Text property and make use of the UpdateSourceTrigger.

UpdateSourceTrigger=PropertyChanged

通过将其设置为 PropertyChanged,您将在每次文本更改时收到通知.

By setting it to PropertyChanged, you will get a notification each and every time the text changes.

这篇关于在将文本输入到 TextBox 时立即触发 TextChanged 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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