private void LoginBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { if (!string.IsNullOrWhiteSpace(LoginBox.Text)) { if (string.IsNullOrWhiteSpace(PasswordBox.Password)) { PasswordBox.Focus(FocusState.Keyboard); } else if (CaptchaForm.Visibility == Visibility.Visible && string.IsNullOrWhiteSpace(CaptchaBox.Text)) { CaptchaBox.Focus(FocusState.Keyboard); } else { ViewModel.LoginCommand.Execute(null); } } } }
private void PasswordBox_OnKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { if (!string.IsNullOrWhiteSpace(PasswordBox.Password)) { if (string.IsNullOrWhiteSpace(LoginBox.Text)) { LoginBox.Focus(FocusState.Keyboard); } else if (CaptchaForm.Visibility == Visibility.Visible && string.IsNullOrWhiteSpace(CaptchaBox.Text)) { CaptchaBox.Focus(FocusState.Keyboard); } else { ((LoginViewModel)DataContext).LoginCommand.Execute(null); } } } }