Answered by:
[UWP]hardware back button behavior

Question
-
Hi,
I haven't got a real tablet like Surface Pro to test on. But I m developing UWP app for Win10-PC and Surface tablet and testing the app using Simulator in VS2015.
I could not confirm for sure but I remember for old WinRT 8 -tablet that when user press the hardware back button , it will navigate to previous page even you did not override the Hardware back button.
My question now is :
base on Simulator in VS2015 and base on this condition : no overriding the hardware back button
is this the correct default behaviour for simulator run in tablet mode such that when user press the back button there is no response or it will do nothing or it will not
navigate to previous page like P1 ->P2 -> P1
Thanks.
- Edited by Xavier Xie-MSFT Friday, August 12, 2016 5:34 AM subject
Thursday, August 11, 2016 9:30 AM
Answers
-
There's 2 back buttons: one in the app window and one in the windows task bar.
The one in the app window goes page to page
The one in windows taskbar goes app to app.
It is easy to get them confused.
when you use SystemNavigationManager.GetForCurrentView().BackRequested for
Page Navigation there is no difference which back button you use from TitleBar or from TaskBar , Also note that TitleBar back button you have to manually enable
Overriding from the norm is never a good idea. An app should behave like any other app in this regard. whether it was a good idea to have 2 different back buttons in tablet mode is questionable, but this is the way the OS is designed at the moment and it will probably not be modified any time soon.
And if I am not mistaken, the established pattern with NavigationHelper class needs the title bar back button to work properly. And then comes the hamburger menu which completely overrides the whole back button navigation.
- Edited by mcosmin Friday, August 12, 2016 7:49 AM
- Proposed as answer by Xavier Xie-MSFT Tuesday, August 16, 2016 11:14 AM
- Marked as answer by Xavier Xie-MSFT Thursday, August 25, 2016 9:40 AM
Friday, August 12, 2016 7:47 AM
All replies
-
Hi,
I haven't got a real tablet like Surface Pro to test on. But I m developing UWP app for Win10-PC and Surface tablet and testing the app using Simulator in VS2015.
I could not confirm for sure but I remember for old WinRT 8 -tablet that when user press the hardware back button , it will navigate to previous page even you did not override the Hardware back button.
My question now is :
base on Simulator in VS2015 and base on this condition : no overriding the hardware back button
is this the correct default behaviour for simulator run in tablet mode such that when user press the back button there is no response or it will do nothing or it will not
navigate to previous page like P1 ->P2 -> P1
Thanks.
Not in Windows 10 nor in Windows 8.x when the user press the hardware back button it navigate to previous page. Instead it navigate to previous App. You must subscribe on BackButton pressed event
public Page2() { this.InitializeComponent(); SystemNavigationManager.GetForCurrentView().BackRequested += Page2_BackRequested; } private void Page2_BackRequested(object sender, BackRequestedEventArgs e) { e.Handled = true; this.Frame.GoBack(); }
For more read here
Navigation design basics for UWP apps
and here
Navigation history and backwards navigation
(Note for back button appear in your TaskBar you should select TabletMode from the ActionCenter)
If If some answer helped you don't forget mark it as answer (this relate also your previous questions)
- Edited by Azat Tazayan Thursday, August 11, 2016 10:53 AM
Thursday, August 11, 2016 10:48 AM -
There's 2 back buttons: one in the app window and one in the windows task bar.
The one in the app window goes page to page
The one in windows taskbar goes app to app.
It is easy to get them confused.
Thursday, August 11, 2016 12:04 PM -
There's 2 back buttons: one in the app window and one in the windows task bar.
The one in the app window goes page to page
The one in windows taskbar goes app to app.
It is easy to get them confused.
when you use SystemNavigationManager.GetForCurrentView().BackRequested for
Page Navigation there is no difference which back button you use from TitleBar or from TaskBar , Also note that TitleBar back button you have to manually enable
- Edited by Azat Tazayan Thursday, August 11, 2016 1:59 PM
Thursday, August 11, 2016 1:58 PM -
There's 2 back buttons: one in the app window and one in the windows task bar.
The one in the app window goes page to page
The one in windows taskbar goes app to app.
It is easy to get them confused.
when you use SystemNavigationManager.GetForCurrentView().BackRequested for
Page Navigation there is no difference which back button you use from TitleBar or from TaskBar , Also note that TitleBar back button you have to manually enable
Overriding from the norm is never a good idea. An app should behave like any other app in this regard. whether it was a good idea to have 2 different back buttons in tablet mode is questionable, but this is the way the OS is designed at the moment and it will probably not be modified any time soon.
And if I am not mistaken, the established pattern with NavigationHelper class needs the title bar back button to work properly. And then comes the hamburger menu which completely overrides the whole back button navigation.
- Edited by mcosmin Friday, August 12, 2016 7:49 AM
- Proposed as answer by Xavier Xie-MSFT Tuesday, August 16, 2016 11:14 AM
- Marked as answer by Xavier Xie-MSFT Thursday, August 25, 2016 9:40 AM
Friday, August 12, 2016 7:47 AM