Discussion on Windows Phone 7 development on the 31st day -- 3rd: Return key

Source: Internet
Author: User

By Jeff Blankenburg

This article is about Windows Phone 7 development on the 31st day"3rd day of the series.

Yesterday, we discussed page navigation and how to simply call NavigationService to reach different pages in the program. The Return key is briefly mentioned, but the complexity of the Return key is worth writing in this series, mainly because you canOverride)The behavior of the Return key.

How does the return key work?

It is similar to the return button in the browser. You can click it to go back through the decision information of the session. It allows you to span multiple sites and each page in these sites. The Return key in Windows Phone works in the same way. It allows you to return to the previously visited page, or even cross-application!

For example, if I:

  1. Open People Hub ).
  2. Select "Jeff Blankenburg" in the contact list ".
  3. Click his home address (to bring us to the map application ).
  4. Click Start.
  5. Start the game.

When you click the return key, it will go back along the list of events that occurred.

Rewrite the return key action

Yes, you are not mistaken. You can redefine the behavior of the Return key as you want. However, this does not mean that you are allowed to perform irresponsible behaviors through such capabilities. When you want to override the return key behavior, you should confirm that what you think "return" means the same as what your users think.

For example, if you open a pop-up box, the user's muscle memory 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.

In another example, if you have a game that relies on a timer or real-time action, it is more appropriate to use the return key to pause the game rather than letting people leave immediately. The following are the guiding principles for such incidents:

  1. You should put yourself in consideration of what the "return" means to users at that moment.
  2. If the user presses the return key again, you should let the default behavior be executed.
  3. Using the return key to pause the game is a good idea, but clicking it again means that they really want to return to the front, so they have to be able to move back.

Here is the code to override the return key in Windows Phone:

Protected override void OnBackKeyPress (System. ComponentModel. CancelEventArgs e)

{

// Your own code. Be conscientious and responsible.

E. Cancel = true; // Cancel the default action.

}

Tomorrow we will discuss the device direction and how to handle the problem in the program.

Address: http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7c-Day-3-The-Back-Button-Paradigm.aspx

Related Article

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.