Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to show the pre-set password in clear text with the PasswordBox control? #158

Open
Bo-Liu-BL opened this issue Aug 23, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@Bo-Liu-BL
Copy link

Bo-Liu-BL commented Aug 23, 2020

Hi experts,

Is it possible to show the pre-set password in clear text with the PasswordBox control?

I have a user scenario as the following:

  1. User connects to a remote server for authentication;
  2. The remote server responds to the user with a pre-set password;
  3. After the user gets the response, the user will be shown an UI with two PasswordBox controls;
  4. The first PasswordBox will show the password in clear text instead of the masked one from the remote server;
  5. The user needs to type it in the another PasswordBox and submit it to the server.

Now I am blocked at the above step #4. The password wouldn't be shown in the PasswordBox.
Note: I am binding the password with another dependency property with the same way as the following:
http://dotnetharbour.blogspot.com/2014/10/mvvm-passwordbox-securepassword-and.html

For the 1st PasswordBox which is to show the password from remote server, the symptom is:

  • If I dont't set the property PasswordRevealMode as "Visible", then the password is shown as dots. But this doesn't satisify my requirement.
  • If I set the property PasswordRevealMode as "Visible", the PasswordBox is always shown empty although it actually has value by debugging.

By inspecting the implementation of the DependencyObject PasswordBoxHelper:
https://github.com/Kinnara/ModernWpf/blob/master/ModernWpf/Controls/Primitives/PasswordBoxHelper.cs

I am wondering whether we need to do anything with the TextBox which is declared as private in the above file?
For example, we could set the TextBox to show the password if we need the clear text.
If yes, then this might be a feature request.

Thanks very much!

@Bo-Liu-BL Bo-Liu-BL changed the title Is is possible to show the pre-set password in clear text with the PasswordBox control? Is it possible to show the pre-set password in clear text with the PasswordBox control? Aug 31, 2020
@Bo-Liu-BL
Copy link
Author

In fact, there are other ways to achieve the purpose.
For example, I could define another TextBox which has the same position/size with the PasswordBox.
The logic is:

  • If need to show the password in clear text, then hide the PasswordBox control and show the TextBox with the password;
  • Otherwise keep the TextBox hidden and show the PasswordBox.
    There have been similar solutions such as this post in stack overflow

However, it will be great to provide this function in the ModernWpf as the TextBox has been in place.

@Kinnara
Copy link
Owner

Kinnara commented Sep 7, 2020

If I set the property PasswordRevealMode as "Visible", the PasswordBox is always shown empty although it actually has value by debugging.

This sounds like a bug. I'll look into it.

@Kinnara
Copy link
Owner

Kinnara commented Sep 7, 2020

Fixed by 1cc1d53. Thanks for bringing this up!

@Bo-Liu-BL
Copy link
Author

Fixed by 1cc1d53. Thanks for bringing this up!

Thank you very much for the fixing, Kinnara!

@Kinnara Kinnara added the bug Something isn't working label Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants