![]() ![]() We would still need to extend the default PasswordBox style with the ability for a "reveal button", but that could be done using an internal attached property. We can reuse the existing PasswordBox styles for the encapsulated PasswordBox and thus not need to keep 2 styles in sync.I see this as having (at least) 2 advantages: This means we would need to ensure these stay in sync.Īnother approach could be to wrap the PasswordBox inside of a custom control (e.g. And since ControlTemplates cannot be extended/modified (but only overridden) in a style, we would effectively create a copy of the default PasswordBox style and add in the reveal button (and TextBox for editing the revealed password). We would need to replicate these 4 in a "reveal flavor". What nags me a bit about this approach is that we have 4 different PasswordBox styles today: default, floating-hint, filled, and outlined (the three latter are derived styles). Sorry about the long response below I agree to the opt-in part of this. I don't know if it would be within the MDIX purview to add a non-password "password box" ( UnsecurePasswordBox maybe?) that explicitly makes the choice not to use the SecureString scheme that PasswordBox uses and be more MVVM friendly. This "hack" lets me using a single binding and its 100% MVVM compatible. In their Home app to setup the Wifi network, they mask it by default but don't require any authentication to unmask the password. I really don't think for most of my needs I really need to visually hide the password, but that seems to be the common interface Google uses. character and that seems to do what I want.A password font is one that replaces all codepoints with a My latest "hack" to do what I want with as little effort as possible is to use a single textbox and swap between a password and standard font. (As a side note, Dotnet even recommends against using SecureString since it doesn't do anything except implement IDisposable on anything but Framework). Like mentioned whether that is secure or not is another discussion. ![]() And generally, PasswordBox (at least in my experience of it) breaks the MVVM paradigm and generally makes my life more difficult for some vague notion of "security". ![]() As for validation, that should "just work" with regular binding validation once there is a simple string attached property to bind to.įor my specific use case, we rarely need a proper SecureString.But having this property allows people to change it, or toggle it based on revealed state if that is desired. For now, the icon can simply default to the standard "eye" (like in the screenshots above). I would add properties PasswordBoxAssist class with several attached properties, a boolean indicating if we are in a revealed state or not, and one for the reveal icon ( PackIconKind enum).It should be something that consumers have to opt-in for, rather than the default. I would create a separate style for this.I would put the attached property within a new PasswordBoxAssist class. ![]() Because the normal password is not a dependency property, registering for events is needed to manually manage synchronization between them.
0 Comments
Leave a Reply. |