Windows phone7 Study Notes 04 -- rewrite the return key

Source: Internet
Author: User

It is unreasonable to roll back to the previous page. For example, if a pop-up box is opened, you may press the return key to close the pop-up box. In this case, their intention is not to leave the application. "return" only means to get rid of the pop-up dialog box. There are two methods for rewriting. The first is to override the onbackkeypress event, and the second is to override the phoneapplicationpage_backkeypress event.

The following code re-writes the return key in Windows Phone

  1. Rewrite the onbackkeypress event

 

Protected override void onbackkeypress (system. componentmodel. canceleventargs E)

 

{

 

E. Cancel = true;

 

If (MessageBox. Show ("Save project ?? "," ", Messageboxbutton. okcancel) = messageboxresult. OK)

 

{

 

App. intilize ();

 

Navigationservice. navigate (New uri ("/mainpage. XAML", urikind. relativeorabsolute ));

 

}

 

}


2. Rewrite the phoneapplicationpage_backkeypress event.
Add event:

  

Rewrite:

  

 

Note that you must not forget to cancel the original return key operation, that is, do not forget E. Cancel = true.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.