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

后端 未结 7 2069
悲哀的现实
悲哀的现实 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条回答
  •  猫巷女王i
    2021-01-01 16:50

    How about make SendKeys Class Working like Winforms.SendKeys

    https://michlg.wordpress.com/2013/02/05/wpf-send-keys/

    public static class SendKeys
    {
        public static void Send(Key key)
        {
            if (Keyboard.PrimaryDevice != null) {
                if (Keyboard.PrimaryDevice.ActiveSource != null) {
                    var e1 = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, key) { RoutedEvent = Keyboard.KeyDownEvent };
                    InputManager.Current.ProcessInput(e1);
                }
            }
        }
    }
    

提交回复
热议问题