private void stackPanel_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
if (FocusManager.GetFocusedElement() == inputTextBox) // Change the inputTextBox to your TextBox name
{
FocusManager.TryMoveFocus(FocusNavigationDirection.Next);
FocusManager.TryMoveFocus(FocusNavigationDirection.Next);
}
else
{
FocusManager.TryMoveFocus(FocusNavigationDirection.Next);
}
// Make sure to set the Handled to true, otherwise the RoutedEvent might fire twice
e.Handled = true;
}
}
你有类似 yourTextBoxName.Focus()
的东西吗?同时使用 KeyDownEvent 为 New Password
文本框检查以下内容
if (e.Key == Key.Enter || e.PlatformKeyCode == 0x0A)
{
confirmPassword.Focus();//change confirmPassword to your controls actual name
}