简体   繁体   English

在WPF窗口中按Enter键登录。

[英]Pressing Enter Key to Login in WPF windows.

I know that assigning the button to the AcceptButton property in a form would allow me to submit the form in Windows Forms. 我知道将按钮分配给表单中的AcceptButton属性将允许我在Windows窗体中提交表单。 The problem I'm having is that I'm using a WPF Window as the login screen and I don't know how to make the button work when the Enter Key is pressed. 我遇到的问题是我使用WPF窗口作为登录屏幕,我不知道在按下Enter键时如何使按钮工作。 There isn't an AcceptButton Property for WPF Windows. WPF Windows没有AcceptButton属性。 Any Help? 任何帮助?

Set IsDefault to True . IsDefault设置为True

<Button IsDefault="True"/>

From MSDN : 来自MSDN

Gets or sets a value that indicates whether a Button is the default button. 获取或设置一个值,该值指示Button是否为默认按钮。 A user invokes the default button by pressing the ENTER key. 用户通过按ENTER键调用默认按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM