我正在为Windows 7开发一个应用程序,我需要屏蔽一个页面…我的解决方案是不注册该帧或清除后面的所有帧
我猜你的意思是你在Back-stack上有一个页面你想要删除——
在新的芒果SDK中,有一个方法你可以尝试NavigationService。RemoveBackEntry
然而,使用布尔值并检查OnNavigatedTo
:
需要返回的页面> 1页:
in App.xaml.cs:
public static bool IsBackwardNavigation = false;
public static string PageContext = string.Empty;
Page2.xaml.cs
:
public void YourFunction()
{
App.PageContext = "MainPage";
App.IsBackwardNavigation = true;
if (NavigationService.CanGoBack)
NavigationService.GoBack();
}
在每一页的OnNavigatedTo
中:
Page1.xaml.cs:
string Page1 = "Page1";
protected override void OnNavigatedTo(object sender, NavigationEventArgs e)
{
if (App.IsBackwardNavigation)
{
if (!Page1.Equals(App.NavigationContext)
{
//since this page's name is not the correct page, the page will go back again.
if (NavigationService.CanGoBack)
NavigationService.GoBack();
}
else
{
//this is the page we're trying to get to
App.IsBackwardNavigation = false;
App.NavigationContext = string.Empty;
}
}
}
}