What's the Best Way to Catch the Return Key in a PasswordBox? (WPF/XAML)

后端 未结 3 1902
-上瘾入骨i
-上瘾入骨i 2021-02-18 15:20

What\'s the best way to catch the return key in a PasswordBox? (WPF/XAML)

I have a TextBox field and a PasswordBox field on my login form (for username and password en

3条回答
  •  星月不相逢
    2021-02-18 15:50

    You could try using a RoutedCommand.

    You can set it on the Command property of the Button.
    You can also add a KeyGesture to the InputBindings of your loginform to bind the Enter key to trigger your RoutedCommand.

    Then add a CommandBinding in the CommandBindings of your loginform to bind the RoutedCommand to Executed handlers in your code and perform or trigger your login validation process.

提交回复
热议问题