Owen Johnson
Owen Johnson

Reputation: 2526

How do I execute code when a user switches back to my UWP app?

In Windows Phone and Windows 8.1, OnNavigatedTo would be invoked when a page became the visible page after navigation from any page. Now, it seems that this method is only called when switching between pages in the current app. How do I execute code when a user switches back to my app from another one (ie using the back button). I've tried the Application.Resuming event, but this is not fired either.

Upvotes: 0

Views: 94

Answers (1)

Petter Hesselberg
Petter Hesselberg

Reputation: 5518

The Application.Resuming event is only called if your app was actually suspended, which might not be the case. However, the application object has OnActivated plus a bunch of scenario-specific overrides; one of those is likely what you want.

Relying on Window.VisibilityChanged sounds iffy if you're targeting other device families than phone.

Upvotes: 0

Related Questions