Q:

WPF change Password property of PasswordBox in PasswordChange event

I'm trying to do the following:
private void PasswordBox_A_PasswordChanged(object sender, RoutedEventArgs e)
{
PasswordBox_A.Password = PasswordBox_A.Password.Replace("\n", "");
}

but the thing is This code is executed infinitely. I just want to make sure that the user doesn't write the string "\n", do yow know other method or maybe how make this code work
Thanks. 

A:

A user should not be able to enter \n in the password box. But anyway, to avoid infinite calling, you could try something like this:
private void PasswordBox_A_PasswordChanged(object sender, RoutedEventArgs e)
{
    if (PasswordBox_A.Password.Contains("\n"))
        PasswordBox_A.Password = PasswordBox_A.Password.Replace("\n", "");
}

