如何更改 PasswordBox 的屏幕键盘 [英] How do I change the on-screen keyboard for a PasswordBox

查看:19
本文介绍了如何更改 PasswordBox 的屏幕键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个盒子,我只想输入一个只有数字的密码(比如 ATM 卡的 PIN),最好的方法是什么?

I have a box that I want to take a password of only numbers (like an ATM-card PIN), how is the best way to do that?

要求:

  • 密码(带有隐藏数字)
  • 输入数字作为默认(仅?)键盘

我尝试过的:

我认为 InputScopes 是可行的方法,但我无法在密码框上设置输入范围.我什至尝试将密码 InputScope 放在普通的 TextBox 上,但这并没有掩盖文本框中字符的外观.建议?

I thought that InputScopes would be the way to go, but I can't set the input scope on a password box. I even tried putting the password InputScope on a normal TextBox, but that didn't mask the appearance of the characters in the text box. Suggestions?

推荐答案

简短版本 - 据我所知,您不是开箱即用的.

Short version - you don't out-of-the-box as far as I know.

PasswordBox 不支持 InputScope,这是完全正确的.我原以为它继承自 TextBox 或文本输入的共同祖先以获取 InputScope,但它直接继承自 Control.而且由于它是一个密封类,因此您也不能继承它并更改它的行为.我认为您也无法使用 ControlTemplate 实现它.

You're absolutely right that PasswordBox don't support InputScope. I would have thought that it inherited from TextBox or a common ancestor for textual input to get InputScope, but it inherits directly from Control. And since it is a sealed class you cannot inherit it and change it behaviour either. I don't think you can achieve it using ControlTemplate either.

因此,您最好的办法可能是创建自己的控件来模仿 PasswordBox 的行为,包括在显示的字符成为隐藏字符之前的第二个长时间延迟.

So your best bet will probably be to create your own control mimicking the behaviour of PasswordBox, including the second long delay before the shown character becomes the hidden character.

这篇关于如何更改 PasswordBox 的屏幕键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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