Mehdi Khademloo
Mehdi Khademloo

Reputation: 2812

in WPF why the PasswordBox and TextBox are different controls?

Already in WinForm we set a property to a TextBox and this easily changes the text style to password. I think this was a really good solution because all manner in TextBox and PasswordBox are same (sometime, we can set one style to these two kind of controls)

My question is: Why now in xaml, the TextBox and PasswordBox are different? What is the technical limitation of that WinForm's solution to dealing with passwords?

Upvotes: 2

Views: 670

Answers (1)

ChrisF
ChrisF

Reputation: 137188

Since the password box contains a sensible password it does not allow cut, copy, undo and redo commands.

Source

Without someone from the design team coming along to tell us for sure, I would suspect that to get this functionality having a separate control was the best way to achieve this.

In addition the PasswordBox is sealed meaning you can't derive your own custom control from it circumventing these restrictions.

MSDN page

So, ultimately the reason they're a separate controls is for security so that the user's password can't be intercepted.

Upvotes: 3

Related Questions