使用 PickFolderAndContinue 方法恢复应用程序的问题

Issues resuming app with PickFolderAndContinue method

我在使用 PickFolderAndContinue 方法后恢复我的应用程序时遇到问题。我一直在尝试偏离 this MSDN 示例中的说明。我一直无法弄清楚如何将 OnActivated 方法更改为 return 到我的设置页面(示例仅使用具有不同内容框架的主页)。

    protected async override void OnActivated(IActivatedEventArgs e)
    {
        base.OnActivated(e);

        ContinuationManager continuationManager = new ContinuationManager();

        Frame rootFrame = CreateRootFrame();
        await RestoreStatusAsync(e.PreviousExecutionState);

        if (rootFrame.Content == null)
        {
            rootFrame.Navigate(typeof(SettingsPage));
        }

        var continuationEventArgs = e as IContinuationActivatedEventArgs;
        if (continuationEventArgs != null)
        {
            // What do i do here to return to my settings page?
            Frame scenarioFrame = SettingsPage.Current.FindName("ScenarioFrame") as Frame; 
            if (scenarioFrame != null)
            {
                // Call ContinuationManager to handle continuation activation 
                continuationManager.Continue(continuationEventArgs, scenarioFrame);
            }
        }

        Window.Current.Activate();
    }

谢谢。

当你的 OnActivated 被调用时,如果你知道你总是想去 SettingsPage 那么你只需要这个代码:

   Frame rootFrame = CreateRootFrame();
    await RestoreStatusAsync(e.PreviousExecutionState);

    if (rootFrame.Content == null)
    {
        rootFrame.Navigate(typeof(SettingsPage));
    }

该代码创建应用程序根框架,并告诉它导航到该特定页面。

这之后的代码使用了ContinuationManager。这是一种机制,用于调用页面以让它知道它正在从 AndContinue 方法返回。这将允许页面为该页面执行任何功能。

FilePicker 还有一个 ContinuationData 属性,您可以在调用 AndContinue 方法之前对其进行设置。此数据可通过 IContinuationActivatedEventArgs 在 OnActivated 中获得。

此博客对 AndContinue 方法有很好的描述: http://blogs.msdn.com/b/wsdevsol/archive/2014/05/08/using-the-andcontinue-methods-in-windows-phone-silverlight-8-1-apps.aspx