Last active
March 5, 2020 19:40
-
-
Save dylanberry/d6c90d6c93a65b389cba61e6d224bdd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool PromptToConfirmExit | |
{ | |
get | |
{ | |
bool promptToConfirmExit = false; | |
if (MainPage is ContentPage) | |
{ | |
promptToConfirmExit = true; | |
} | |
else if (MainPage is Xamarin.Forms.MasterDetailPage masterDetailPage | |
&& masterDetailPage.Detail is NavigationPage detailNavigationPage) | |
{ | |
promptToConfirmExit = detailNavigationPage.Navigation.NavigationStack.Count <= 1; | |
} | |
else if (MainPage is NavigationPage mainPage) | |
{ | |
if (mainPage.CurrentPage is TabbedPage tabbedPage | |
&& tabbedPage.CurrentPage is NavigationPage navigationPage) | |
{ | |
promptToConfirmExit = navigationPage.Navigation.NavigationStack.Count <= 1; | |
} | |
else | |
{ | |
promptToConfirmExit = mainPage.Navigation.NavigationStack.Count <= 1; | |
} | |
} | |
else if (MainPage is TabbedPage tabbedPage | |
&& tabbedPage.CurrentPage is NavigationPage navigationPage) | |
{ | |
promptToConfirmExit = navigationPage.Navigation.NavigationStack.Count <= 1; | |
} | |
return promptToConfirmExit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment