【问题标题】:Windows phone extended splash back navigationWindows phone 扩展后溅导航
【发布时间】:2013-07-12 20:32:18
【问题描述】:

我为我的 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));    
    }

【问题讨论】:

标签: navigation windows-phone-8 splash-screen back


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
    
        while (this.NavigationService.BackStack.Any())
        {
            this.NavigationService.RemoveBackEntry();
        }
    }
    

    它会清理后台堆栈,以便应用在按下返回按钮时退出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多