首次打开特定页面

时间:2013-09-09 11:56:48

标签: c# windows-phone-8

WMAppManifest.xml我将页面A设为默认页面。

虽然99.9%的时间都很好,但我需要用户在应用首次运行时看到第B页。

我不知道从哪里开始,除了检查(在页面A中)应用程序的IsolatedStorageSettings属性中是否存在“firstRun”键,并将用户导航到页面B.

但这对我来说听起来像是一个黑客。有没有良好的实践解决方案?

编辑:我尝试使用谷歌搜索,但我不确定使用哪些关键字。

1 个答案:

答案 0 :(得分:2)

自定义UriMapper正是您所需要的。这里is the example

public class YourUriMapper : UriMapperBase
{
    public override Uri MapUri(Uri uri)
    {
        if (uri.OriginalString == "/PageA.xaml")
        {
            if (AppSettings.FirstRun == true)
            {
                uri = new Uri("/PageB.xaml", UriKind.Relative);
            }
            else
            {
                uri = new Uri("/PageA.xaml", UriKind.Relative);
            }
        }
        return uri;
    }
}

其中AppSettings是用于存储应用程序设置的用户定义类。