You can use the NavigationService.BackStack property and check the first entry in the reverse stack on the page as it is moved.
If this check is to be performed on several pages, it can be placed in the base class. Also, if your situation matches the eula / login script mentioned by @Skomski, his answer makes the most sense.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var lastPage = NavigationService.BackStack.FirstOrDefault();
if (lastPage != null && lastPage.Source.ToString() == "/MainPage.xaml")
{
NavigationService.RemoveBackEntry();
}
}
source
share