简体   繁体   中英

How to trigger button click event on pressing enter button in c#

I am creating a login form in windows phone app , I want to trigger login button event on pressing enter button from finishing the form.

Requirement: While clicking enter button from last text field in login page should trigger login button event..

Code sample I know how to move from one text field to another on clicking enter button as below

private void passkeydown(object sender, KeyEventArgs e)
{
  if (e.Key == Key.Enter)
 {
  nextfield .Focus();
  }
 }

But I don't know how to trigger button click event here.

Try This:

if (e.Key == Key.Enter)
{
  LoginButton_Click(sender,e); //here LoginButton_Click is click eventhandler
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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