如何在C#中设置"First-Launch-View"

Fla*_*der 4 c# windows xaml uwp

我到处搜索,但我找不到我的问题的教程.我想在第一次启动应用程序时设置要显示的页面.像这样的东西:

首次发布:Greeting.xaml> Setting.xaml> MainPage.xaml

定期启动直接进入MainPage.

我怎样才能做到这一点?

我不是指Splashscreen,我的意思是一个页面,它只在你第一次启动App时显示,就像一个小教程.

Pet*_*erg 5

您的典型模板生成App.xaml.cs在其OnLaunched方法中具有以下类似内容:

if (rootFrame.Content == null)
{
    rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
Run Code Online (Sandbox Code Playgroud)

这是您导航到第一页的位置.对于第一次运行的特殊情况,请执行以下操作:

if (rootFrame.Content == null)
{
    IPropertySet roamingProperties = ApplicationData.Current.RoamingSettings.Values;
    if (roamingProperties.ContainsKey("HasBeenHereBefore"))
    {
        // The normal case
        rootFrame.Navigate(typeof(MainPage), e.Arguments);
    }
    else
    {
        // The first-time case
        rootFrame.Navigate(typeof(GreetingsPage), e.Arguments);
        roamingProperties["HasBeenHereBefore"] = bool.TrueString; // Doesn't really matter what
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,问候页面应导航到您的设置页面,该页面应导航到您的主页面.

通过使用漫游设置,用户登录到其他计算机时将看不到第一次显示的屏幕.