Windows 8中二次动态磁贴的问题

时间:2012-11-19 21:23:39

标签: windows-8

我遇到了二次活动磁贴的问题。我把它钉在我的应用程序中,我想要 它让用户进入深层链接,并将其固定。 在App.xaml.cs文件中,我将其添加到onlaunched事件:

if (rootFrame.Content == null)
        {
            // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren
            // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter
            // übergeben werden

            if (!string.IsNullOrEmpty(args.Arguments))
            {
                rootFrame.Navigate(typeof(qurandb));//, args.Arguments);
            }
            else
            {
                //  rootFrame.Navigate(typeof(qurandb), args.Arguments);
                rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups");
            }

        /*    if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
            {
                throw new Exception("Failed to create initial page");
            } */
        }

我的问题是,这只适用于第一次启动应用时。当我稍后点击辅助磁贴(应用程序正在恢复)时,我没有到达我想要的目的地,但到了这一点,当我暂停应用程序的时候。

有人可以帮我吗?

2 个答案:

答案 0 :(得分:1)

单击辅助磁贴时,将调用应用程序的OnLaunched事件。您提供的代码假定它仅在rootFrame.Content为空时调用,并且如果您的应用程序已在运行,则不会导航到相应的页面。代码需要处理帧内容不为空的情况。

if (rootFrame.Content == null)
{
    ...
} else {
    // Need to handle the case where rootFrame.Content is not null
}

答案 1 :(得分:0)

您需要按如下方式处理OnResuming事件:

在App.xaml.cs

public App() 
{
    //...
    this.Resuming += OnResuming; 
    //...
}

//...

private void OnResuming(object sender, object e) 
{
    //there are no args here to access. So need to figure out some way to decide what page to show
    bool showShowQuranDb = true; //your logic here
    if (shouldShowQuranDb)
    {
        rootFrame.Navigate(typeof(qurandb));
    }
    else
    {
        rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups");
    }
}
相关问题