How can I do this in XAML:
PSEUDO-CODE:
<TextBox Text="{Binding Password}" Type="Password"/>
so that the user sees stars or dots when he is typing in the password.
I've tried various examples which suggest PasswordChar and PasswordBox but can't get these to work.
e.g. I can do this as shown here:
<PasswordBox Grid.Column="1" Grid.Row="1" PasswordChar="*"/>
but I of course want to bind the Text property to my ViewModel so I can send the value the bound TextBox when the button is clicked (not working with code behind), I want to do this:
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Login}" Style="{StaticResource FormTextBox}"/> <PasswordBox Grid.Column="1" Grid.Row="1" Text="{Binding Password}" PasswordChar="*" Style="{StaticResource FormTextBox}"/>
But PasswordBox doesn't have a Text property.
WPF comes with a built-in PasswordBox control that allows you to handle and manage passwords in a WPF application. A PasswordBox control as a TextBox control with masking feature enabled. The PasswordBox control allows you to hide the characters and limit the number of characters to be typed in the editable area.
A password box is a text input box that conceals the characters typed into it for the purpose of privacy. A password box looks like a text box, except that it renders placeholder characters in place of the text that has been entered.
To get or set the Password in a PasswordBox, use the Password property. Such as
string password = PasswordBox.Password;
This doesn't support Databinding as far as I know, so you'd have to set the value in the codebehind, and update it accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With