question

Ivanich avatar image
0 Votes"
Ivanich asked Ivanich answered

AppWindow and system Back button

What is recommended way to handle system Back button click with new AppWindow APIs?

Let's say, we have main window and secondary AppWindow opened side-by-side on a tablet. User pressed hardware or software Back button and SystemNavigationManager fires BackRequested event. But secondary AppWindow shares CoreWindow with main window and it is not clear which of them should handle this event. Unlike old Window, AppWindow does not have events to track whether it is active or not.


windows-uwp
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Ivanich we recommend drawing an in-app back button for clarity. You could use NavigationView instead the AppWindow to navigate the page, then set NavigationView.IsBackButtonVisible Property to true.

1 Vote 1 ·

Thanks! I ended up with closing secondary window when its visibility changes to hidden in the tablet mode. AppWindow has Changed event, IsVisible and WindowingEnvironment.Kind properties that allow to do this.

0 Votes 0 ·

@Ivanich I'm glad to hear that your issue has been solved. You could upload your solution as an answer then accept your own answer, which will help others that face the same question.

0 Votes 0 ·

1 Answer

Ivanich avatar image
0 Votes"
Ivanich answered

It seems like AppWindow cannot handle system back button events, moreover, SystemNavigationManager.BackRequested does not fire when current active window is AppWindow. Instead of processing this event, AppWindow just hides, so only way to close it when user pressed system back button is handling visibility changes. AppWindow has Changed event and IsVisible property. WindowingEnvironment.Kind in tablet mode is set to Tiled.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.