How do I change the on-screen keyboard for a PasswordBox
Asked Answered
B

1

3

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?

Requirements:

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

What I've tried:

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?

Babism answered 6/1, 2011 at 7:29 Comment(0)
R
3

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

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.

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.

Race answered 6/1, 2011 at 11:50 Comment(4)
Eew, is there not a better way?Babism
Sorry. I don't think so but I would be glad if someone proved me wrong. :)Race
So, while I think your answer is probably correct, I was also hoping for a different solution. So barring a link or some evidence that you're correct, I'm going to leave this question unanswered a better solution?Babism
But that does mean that I would love a nice official post somewhere stating you're correct so I can stop worrying about it :DBabism

© 2022 - 2024 — McMap. All rights reserved.