0

I have this Passwordbox with this trigger :

<PasswordBox>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="PasswordChanged">
            <i:InvokeCommandAction Command="{Binding PasswordChanged}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</PasswordBox>

How can I, in my RelayCommand, get the content of my PasswordBox?

This is my relay command :

PasswordChanged = new RelayCommand<object>(param => this.GoPasswordChanged());

private void GoPasswordChanged()
{      
}
Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62

1 Answers1

0

I found the solution, I had just to change :

<i:InvokeCommandAction Command="{Binding PasswordChanged}" />

To :

 <i:InvokeCommandAction Command="{Binding PasswordChanged}" CommandParameter="{Binding ElementName=PasswordBoxInput}" />

And :

PasswordChanged = new RelayCommand<object>(param => this.GoPasswordChanged(param));

private void GoPasswordChanged(param)
        {

        }

To :

private void GoPasswordChanged(object param)
        {
            var passwordBox = param as PasswordBox;
            var password = passwordBox.Password;
        }
  • IMHO Bind your password as a property in the viewmodel. So you directly access from the viewmodel – Eldho Sep 19 '16 at 12:35