XMAL
<PasswordBox PasswordChar="*" PasswordChanged="PasswordBox_PasswordChanged" Background="#545d6a" Foreground="White" FontSize="18"/>
Код за
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
if (this.DataContext != null)
{ ((dynamic)this.DataContext).SecurePassword = ((PasswordBox)sender).SecurePassword; }
}
У меня есть класс Klant со свойством Paswoord, которое я хочу сравнить с secureString.
ViewModel
public SecureString SecurePassword { private get; set; }
Klant = DataBaseOperations.OphalenKlantViaUsername(UserName);
if (Klant != null)
{
if (Klant.Paswoord == SecurePassword.ToString())
{
the password is correct and the program continues
}
else
{
MessageBox.Show("the password is incorrect");
}
}
else
{
User does not exist.
}
Кто-нибудь может мне помочь?