1

I'm trying to construct a TextBox in which the use can enter a confirmation code. One of the placeholder dashes remove each time the user enters a digit, until all digits of the code are entered and none of the dashes are left. As soon as that happens, a popup for confirmation appears.

enter image description here

I understand that I need to put restriction of the number of the digits that can be entered, along with the restriction for the input to only be numerical and I have implemented these. Other than that, I'm blank.
How do I get the placeholders that disappears simultaneously with the input? How do I get to have the content stretched? Any help?

NOTE: The said duplicate does not answer my question. The placeholders have to go one by one with each digit entered, rather than disappearing immediately as soon as some input is entered.

Bella Swan
  • 153
  • 10

1 Answers1

1

Xceed's free version of their toolkit includes a masked textbox. I think that can do what you want. https://github.com/xceedsoftware/wpftoolkit/wiki/MaskedTextBox

If that's not suitable for some reason then you could write something yourself fairly easily. Rather than one textbox I would suggest use a textbox per piece the user will input. Textbox then a textblock for the dash, then a textbox then a textblock for the next dash. And so on. You could do this individually or use a horizontally arranged itemscontrol and bind a collection of viewmodels templated out into textboxes and textblocks.

Style the textboxes to hide their borders and put them inside a label or a panel with a border round it.

Andy
  • 11,864
  • 2
  • 17
  • 20
  • The link you provided specifically includes a decimal and comma placeholder only, as far as I can see, at least. Also, it doesn't provide the functionality of those placeholders disappearing one by one – Bella Swan Sep 02 '19 at 07:29