Reputation: 570
I am developing a UWP app in that I want to run a set of code whenever user get back to the app after switching from it.
Here when user switching to another app it may be a UWP or desktop app that time my app still running and open but focus is not on it. When user switching back to my app want to run some set of code.
Like how we are having a got focus and lost focus on a UI element, Similarly want to know do we have such kind of events for the app.
I have used Got focus event on the page but it is not firing at all. Later I get to know that we have some events on Window.Current.CoreWindow in that first I used VisibilityChanged event but it is firing only when I minimise and maximise the app.
Later I used PointerEntered event using this I am able to achieve my requirement. But I want to know is it the correct event I am using or do we have any other event which is more better than pointer entered.
Note: It is an UWP app so I am targeting on multiple devices, I want an event that works on all targeted devices.
Thanks.
Upvotes: 0
Views: 327
Reputation: 531
You are basically asking wether your App is currently focused or not. In UWPs that can be tracked using the Window.Activated event.
Upvotes: 1