How do the App and Window lifecycle events relate?
Short answer
The Application creates Windows; each Window raises Created, Activated, Deactivated, Stopped, Resumed, and Destroying. App-level state changes map to the active window's events.
Advertisement
AModel answer
The Application creates Windows; each Window raises Created, Activated, Deactivated, Stopped, Resumed, and Destroying. App-level state changes map to the active window's events. Use them for app-wide concerns (persist on Stopped, refresh on Resumed), while page OnAppearing/OnDisappearing handle per-screen concerns.
window.Activated += (s, e) => _analytics.TrackForeground();
window.Deactivated += (s, e) => _analytics.TrackBackground();Real-world example
Analytics logs foreground/background transitions from window Activated/Deactivated events across the whole app.
Likely follow-ups
- Window events vs page events? | Which fires when backgrounded?
Related topics