There is no way in WPF Navigation to look at the Back Stack of pages.
You have a number of different choices. Here are two off the top of my head:
1. Clear history when "User B" logs in:
public void ClearHistory()
{
if (!this.Frame.CanGoBack && !this.Frame.CanGoForward)
{
return;
}
var entry = this.Frame.RemoveBackEntry();
while (entry != null)
{
entry = this.Frame.RemoveBackEntry();
}
this.Frame.Navigate(new PageFunction<string>() { RemoveFromJournal = true });
}
2. Custom History tracking:
You would need to hook into the NavigationService events and keep a history yourself. Then you can peek back into the history and issue a
NavigationService.RemoveBackEntry()
to remove the page that "User B" is not allowed access to.