For security reasons, WPF does not provide a dependency property for the Password PasswordBox property (ref. 1 , 2 ), therefore, binding command parameters does not work.
You can associate the command argument with PasswordBox, then access the corresponding property from your implementation:
<Button Command="{Binding ClickCommand}" CommandParameter="{Binding ElementName=pbPassword}">
public void Execute(object parameter)
{
var passwordBox = (PasswordBox)parameter;
var value = passwordBox.Password;
}
You might want to consider other options that are not related to saving the password in memory as plain text.
Hope this helps,
Ben
source
share