Answer the question
In order to leave comments, you need to log in
How to set Binding for PasswordBox?
In the authorization window for the PasswordBox, you need to bing . I found the right example , but it is difficult for me to understand, and even in English. I would like to get sensible explanations on how to perform this binding or get a simple example.
Answer the question
In order to leave comments, you need to log in
Binding for PasswordBox is not implemented quite intentionally, so that it would not be so easy to intercept the password entered in the field.
As a standard and relatively safe practice, I often use passing a PasswordBox as a parameter to the login command.
<TextBox Text="{Binding Login}" x:Name="TbxLogin" />
<PasswordBox x:Name="PasswordBox" />
<Button Content="Log in" Command="{Binding SigninCommand}"
CommandParameter="{Binding ElementName=PasswordBox}" IsDefault="True" />
public ICommand SigninCommand { get; set; }
private void Signin(object param)
{
var passwordBox = param as PasswordBox;
if (passwordBox == null)
return;
var password = passwordBox.Password;
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question