I'm wondering if this is at all possible with all the security involved with the PasswordBox control:
I have a XAML form (C#/WPF) where users will configure a database access. In that form i'm using a PasswordBox to get the SQL Server user password.
Since this data is saved to disk for future use (in a pasword protected SQL Server CE database file), while on first run there is no password set, if the user comes back and needs to edit the SQL connection for some reason, then there could be a password kept from the previous configuration (unless he used Windows Authentication rather than SQL User Authentication)
So I want to show an empty PasswordBox on the first run but if there's a password set already, when the user returns I want to show X number of '*' (to give indication that there is a password in place.
Since PasswordBox.Password isn't bindable, I can only choose to always show it empty or always show a fixed number of '*' (by setting a default Password that doesn't actually represent the real password).
Is there any alternative (besides something like the PasswordBox Helper that injects binding of course - i'd rather not go that path as there might be a reason i haven't considered for MS to choose not to make it bindable even to a SecureString)?
PasswordBox.Password = "ReadPassword";
PasswordBox
doesn't really fitsMVVM
, but you can write attached behavior to setPasswordBox.SecurePassword
(which isSecureString
). This behavior has to have access to existing password (again asSecureString
in someUser
class) or put some fake password (but then you can usePasswordBox.Password
simply) if e.g.User.IsLogged
is set.