简体   繁体   中英

Block double byte chars in a textbox

I am working on a WPF .net 3.5 application.

I need to create my own Passwordbox, because of security issues with the built in one. the new PasswordwordBox is based on a regular TextBox.

Everything is working fine, only that in the WPF Passwordbox double bytes characters are blocked, and I want to add this behavior also to my new PasswordBox.

How can I do that?

Since you actually want to prevent IMEs from displaying characters you should disable the IME for your password box instead of trying to block characters with high code-points.

To disable the IME for a certain WPF textbox use: InputMethod.SetIsInputMethodEnabled(myTextBox, false) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM