I'm writing a .NET Maui app and I have a content page where hen it opens at the start of the program and the user clicks the Cancel button I want the entire application to close.
However, if the same page is opened at some point within the program and the user clicks the Cancel button, I would like only the current content page to close and the application to continue.
To me, this sounds like an if-else command on the Cancel button.
I do have all the content pages I want to access in a folder called Pages.
My real question is:
Is there a way to determine if a content page was opened from application start up?
You can check the App lifecycle of the Maui. Apps generally have four execution states: not running, running, deactivated, and stopped.
Usually, you can overwrite the
Createdmethod to detect if the app is started for the first time. When the app is started, the Created and Activated events are raised and the app is running.If the user returns to the running app, the
Resumingevent is raised and app is running.