private void send_loginForm(object sender, RoutedEventArgs e) { User userToConnect = dataUtils.GetUserByMailAdress(MailAdressTextBox.Text); if (userToConnect != null && PasswordTextBox.Password == userToConnect.Password) { UserConnected.SetUserConnected(userToConnect); var mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } else { PasswordTextBox.Clear(); ErrorMessage.Visibility = Visibility.Visible; } }