Windows phone 7 如何从后台堆栈中删除除当前页面之外的所有历史记录?
我已重写此方法:Windows phone 7 如何从后台堆栈中删除除当前页面之外的所有历史记录?,windows-phone-7,windows-mobile,windows-phone-7.1,Windows Phone 7,Windows Mobile,Windows Phone 7.1,我已重写此方法: protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { base.OnBackKeyPress(e); IAsyncResult guide = Guide.BeginShowMessageBox( "Alert", "Do you want to go to the Menu Page?", new string[] {
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
base.OnBackKeyPress(e);
IAsyncResult guide = Guide.BeginShowMessageBox(
"Alert", "Do you want to go to the Menu Page?",
new string[] { "YES", "NO" }, 0,
MessageBoxIcon.Alert, null, null);
int result = (int)Guide.EndShowMessageBox(guide);
if (result == 0) // YES
{
NavigationService.Navigate(new Uri("/MenuPage.xaml", UriKind.RelativeOrAbsolute));
}
else // NO
{
}
}
现在,当我按下“否”键时,它仍然会将我带回到上一页,我只想覆盖此功能,使其仅停留在当前页面上,而不重新启动页面。我可以吗?您可以按如下方式“取消”活动:
e.Cancel = true;
在代码的“是”路径中执行的操作可能不会很好地工作。导航到MenuPage可能会在导航堆栈中创建错误的导航路径。首先尝试调用NavigationService.RemoveBackEntry(仅限7.1)或NavigationService.GoBack()几次。请看第9频道的这段视频,了解相关说明: