Nick
Nick

Reputation: 3461

How to programmatically do the same as back button does?

I have an app originated from "DirectX and XAML" project template. The main processing is made in a worker thread, and when some input event occures on main thread (like touch or back button pressing), I save it in a special storage and then process on the worker thread's game tick.

Due to that deferred nature of input handling, I cannot immediately decide should back button pressing be consumed or passed through. And I always mark it as consumed.

But if worker thread later decides that back button should be handled naturally (it means exiting the app), how do I achieve this? I know about Application.Current.Terminate();, but I hope there should be more elegant way to programmatically "press back button".

Upvotes: 0

Views: 35

Answers (1)

McGarnagle
McGarnagle

Reputation: 102793

I suppose you would want to use the NavigationService

if (NavigationService.CanGoBack)
    NavigationService.GoBack();

Upvotes: 1

Related Questions