什么是赶上了PasswordBox Return键的最佳方法? (WPF / XAML) [英] What's the Best Way to Catch the Return Key in a PasswordBox? (WPF/XAML)

查看:250
本文介绍了什么是赶上了PasswordBox Return键的最佳方法? (WPF / XAML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是赶在PasswordBox返回键的最佳方法? (WPF / XAML)

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

我有一个文本框字段和PasswordBox场在我的登录表单(用户名和密码输入)。我也有一个登录按钮,它调用执行的登录验证过程的方法。

I have a TextBox field and a PasswordBox field on my login form (for username and password entry). I also have a login button which invokes the method that performs the login validation process.

我需要回车键做出同样的反应在PasswordBox,从而使用户可以选择输入自己的用户名和密码,只需点击返回到登录。

I need to make the Return key react the same way in the PasswordBox, so that the user can have the option enter their username and password and simply hit Return to log in.

有谁知道这是如何在WPF中做了什么?任何帮助是AP preciated。

Does anyone know how this is done in WPF? Any help is appreciated.

推荐答案

还有一个更简单的机制来激活按钮的code。 WPF Button类提供了一个名为ISDEFAULT财产。如果设置为true,如果你preSS回报,同时在窗口中的某些对象具有焦点,按钮的单击事件的code会被自动触发。这种机制的工作原理是用passwordbox魅力。

There is an even easier mechanism to activate the button's code. WPF Button class provides a property called IsDefault. When set to true, if you press return while some objects in the window have focus, the code of the click event of the button will be fired automatically. This mechanism works like a charm with the passwordbox.

这篇关于什么是赶上了PasswordBox Return键的最佳方法? (WPF / XAML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆