How do I simulate a Tab key press when Return is pressed in a WPF application?

后端 未结 7 2055
悲哀的现实
悲哀的现实 2021-01-01 16:37

In a WPF application, i have a window that has a lot of fields. When the user uses the TAB key after filling each field, windows understands that it moves on to the next. Th

7条回答
  •  不思量自难忘°
    2021-01-01 16:53

    I think the best solution is:

    var ue = e.OriginalSource as FrameworkElement;
    
    if (e.Key == Key.Return)
    {
        e.Handled = true;
        ue.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    }
    

提交回复
热议问题