导航到NewPage.xaml时,沿参数传递,以便知道何时从后台堆栈中删除前一页。
你可以这样做,因为这样的:
当从导航CurrentPage.xaml到NewPage.xaml通沿参数
bool remove = true;
String removeParam = remove ? bool.TrueString : bool.FalseString;
NavigationService.Navigate(new Uri("/NewPage.xaml?removePrevious="+removeParam , UriKind.Relative));
在NewPage公司的的OnNavigatedTo事件.xaml,检查是否删除前一页。
bool remove = false;
if (NavigationContext.QueryString.ContainsKey("removePrevious"))
{
remove = ((string)NavigationContext.QueryString["removePrevious"]).Equals(bool.TrueString);
NavigationContext.QueryString.Remove("removePrevious");
}
if(remove)
{
NavigationService.RemoveBackEntry();
}
这样一来,你可以,如果你想从堆栈中删除它在CurrentPage.xaml决定。
现在我们如何在Windows应用商店应用上做到这一点?看到我们似乎没有'RemoveBackEntry()'? – GONeale
我还没有看到,我所知道的是,这对WP7有效。如果我碰巧遇到了答案,我会在这里发布。 – akalucas