I seen that passwordreveal method is not working for passwordbox in wpf, is there any way that I can show and hide password via checkbox?
I expect to show/ hide functionality exist in passwordbox in wpf
Or I just need to use text box to achieve this functionality
PasswordBoxdoesn't have that functionality built in. The original design pre-dates when that option became popular on websites etc.A simple solution is to build a
UserControlthat switches between a plainTextBoxorPasswordBox.EnhancedPasswordBox.xaml
EnhancedPasswordBox.xaml.cs
Hidden:
Visible:
Annoyingly PasswordBox doesn't let you bind to the password, but the
UserControlexposes its ownPasswordproperty to abstract that detail away.A reader may wonder whether it would be better to use a
SecureStringhere for the binding. You certainly could, but given the option to make the password visible, the plaintext string is going to exist in memory - probably in many places - no matter what, so you'd gain very little security (and a big amount of inconvenience) by doing so.