2013-07-12 89 views
1

我爲我的Windows手機應用程序創建了一個擴展啓動畫面,但現在每次我按回主頁時,它都會重新加載擴展閃屏。是否有可能將其從導航堆棧中移除並讓應用程序執行application_closing事件?飛濺Windows手機擴展飛濺回導航

代碼:

public partial class ExtendedSplashScreen : PhoneApplicationPage 
{ 
    public ExtendedSplashScreen() 
    { 
     InitializeComponent(); 

     //Call MainPage from ExtendedSplashScreen after some delay    
     Splash_Screen(); 
    } 

    async void Splash_Screen() 
    { 
     await Task.Delay(TimeSpan.FromSeconds(3)); // set your desired delay    
     NavigationService.Navigate(new Uri("/Screens/HomeScreen.xaml", UriKind.Relative));  
    } 
+0

可能重複的[如何刪除一個窗口的手機backstack?](http://stackoverflow.com/questions/10510798/how-to-remove-one-page-of-windows-phone-backstack) –

回答

0

是你可以從後堆棧中刪除它,試試這個

int a = NavigationService.BackStack.Count(); while (a > 0) { this.NavigationService.RemoveBackEntry(); a = NavigationService.BackStack.Count(); } 這裏a> 0時使用,因爲沒有什麼應該是befour主頁。

0

將這個代碼在HomeScreen.xaml.cs文件:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
{ 
    base.OnNavigatedTo(e); 

    while (this.NavigationService.BackStack.Any()) 
    { 
     this.NavigationService.RemoveBackEntry(); 
    } 
} 

它將清除返回堆棧,這樣按下後退按鈕時,應用程序退出。