private void LoginTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { LoginButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } }
private void LoginTextKeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Enter) { LoginButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); } }
private void Valider2Button_Click(object sender, RoutedEventArgs e) { if (IDBox.Text != "" && PswdBox.Password != "") { username = IDBox.Text; password = PswdBox.Password; string connectionString = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + username + ";PASSWORD="******"Username ou mot de passe erroné.", "Login Failed !", MessageBoxButton.OK, MessageBoxImage.Hand); } } else { MessageBox.Show("Attention ! Il faut remplir tous les champs necessaires !", "Erreur !", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void usernamePasswordTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { LoginButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); } }
private void UsernameTextBox_OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { UsernameTextBox.Background = _validColorBrush; LoginButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); } }
private void PasswordBox_OnKeyDown(object sender, KeyEventArgs e) { ClearLoginFailed(); CheckUsername(UsernameTextBox, EmailFormatErrorMessage); if (e.Key == Key.Return) { LoginButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); } }
/// <summary> /// Handle the focus between elements when Enter is pressed /// </summary> private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (UserInput.IsFocused && UserInput.Text.Length != 0 && PasswordInput.Password.Length == 0) { PasswordInput.Focus(); } else { LoginButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } } }