1

我为我的 Windows Phone 应用程序创建了一个扩展的启动画面,但现在每次我在主页上按回它都会重新加载扩展的启动画面。是否可以将其从导航堆栈中删除并让应用程序执行 application_closure 事件?

飞溅代码:

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));    
    }
4

2 回答 2

0

将此代码放在 HomeScreen.xaml.cs 文件中:

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

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

它将清理后台堆栈,以便应用程序在按下后退按钮时退出。

于 2013-07-12T12:32:18.417 回答
0

是的,您可以将其从后堆栈中删除,试试这个

int a = NavigationService.BackStack.Count(); while (a > 0) { this.NavigationService.RemoveBackEntry(); a = NavigationService.BackStack.Count(); } 这里使用了 > 0,因为主页前不应该有任何内容。

于 2013-07-12T12:31:35.920 回答