How to change the on-screen keyboard for PasswordBox

I have a field in which I want to take the password only with numbers (for example, with a PIN code at an ATM), what is the best way to do this?

Requirements:

  • Password (with hidden numbers)
  • Entering numbers as the default keyboard (only?)

What I tried:

I thought InputScopes would be a way, but I cannot set the input area in the password field. I even tried to put the InputScope password in a regular TextBox, but this did not mask the appearance of characters in the text field. Suggestions?

+3
source share
1 answer

Short version - as far as I know, you are not out of the box.

You are absolutely right that PasswordBox does not support InputScope. I would think that he inherited from TextBox or a common ancestor for text input to get InputScope, but it inherits directly from Control. And since this is a private class, you cannot inherit it and change its behavior. I do not think you can achieve this with a ControlTemplate.

Thus, it is best to create your own control that mimics the behavior of the PasswordBox, including a second long delay before the displayed character becomes hidden.

+3
source

Source: https://habr.com/ru/post/913946/


All Articles