2011-09-03 44 views

回答

2

猜你的意思是你有,你要刪除的返回堆棧上的一個頁面 -

在新芒果SDK,還有一個方法,你可以嘗試NavigationService.RemoveBackEntry

然而,它可能是更容易只使用一個布爾值,並在OnNavigatedTo檢查:

在頁面,您需要回去> 1頁:

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; 


     } 

    } 
     } 
    } 
相關問題