In this tutorial, we learn how to handle hardware back button pressed event in Windows Phone project that is built using HTML/JS/CSS (WinJS).
Step 1
Firstly, create a Windows Phone WinJS project. File > New Project > Other Languages > JavaScript > Windows 8 > Windows Phone > Blank App (Windows Phone). Name it “BackPress” and click OK.

Step 2
In the default.js file, add the following highlighted code snippet. Here ‘return true’ prevents the app from closing the app.

Step 3
Run the application in your device or emulator and tap the hardware button and you get the alert.

You can also get the complete project from GitHub https://github.com/olikishor/BackPressWP.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

SubashPosted Oct 23, 2016, 9:17 PM
Goodshare