private void Button_Click(object sender, RoutedEventArgs e) { List <Patient> patients = m.GetAllPatients(); string username; string password; enteredUsername = Username.Text; string enteredPassword = Password.Password; for (int i = 0; i < patients.Count; i++) { username = patients[i].Username; password = patients[i].Password; if (enteredUsername == username && enteredPassword == password) { WindowPatient window = new WindowPatient(); Close(); window.Show(); } } InvalidInfoLabel.Content = "* invalid username or password"; }