Comment utiliser CommandParameters pour Binding un passwordbox?
Hello les gars,
Je voudrai savoir comment marche le command Parameters?
Dans ma View :
Code:
1 2 3 4
| PasswordBox x:Name=Password_field
Button Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName=Password_field}" |
Dans mon viewmodel
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public RelayCommand LoginCommand { get; set; }
private string password;
public ConnexionViewModel()
{
InscriptionViewCommand = new RelayCommand(executeActionInscription);
LoginCommand = new RelayCommand(executeActionLogin);
}
public string Password
{
get { return this.password; }
set
{
// Implement with property changed handling for INotifyPropertyChanged
if (!string.Equals(this.password, value))
{
this.password = value;
this.RaisePropertyChanged(); // Method to raise the PropertyChanged event in your BaseViewModel class...
}
}
}
public void executeActionLogin(object parameters)
{
var passwordBox = parameter as PasswordBox;
this.password = passwordBox.Password;
Page.Frame.Navigate(typeof(IndexView));
Debug.WriteLine(this.email);
Debug.WriteLine(this.password);
} |
Le probleme vient de cette ligne :
LoginCommand = new RelayCommand(executeActionLogin);
Il aime pas que j'ai mis en parameters object parameters.
Mais quand je suis les forums , il n'en mette pas.
Pouvez vous m'aider?