WPF: Textbox not firing onTextInput event

谁说胖子不能爱 提交于 2019-11-30 11:51:53

Your handler for the TextInput event is not fired because the TextBox is handling the event. You could try using the TextChanged event instead, since really you just want to know when characters were added or removed from the TextBox.

Lavesh
InitializeComponent();
textbox.AddHandler(TextBox.TextInputEvent, 
                   new TextCompositionEventHandler(TextBox_TextInput_1), 
                   true);

Use "PreviewTextInput" instead, it will work.

Create a new class derived from TextBox. In the new class override the OnTextInput method. Your OnTextInput method will get called before the TextBox gets it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!