How to install "First-Launch-View" in C #

I searched everywhere, but I can not find a tutorial for my problem. I want to set a page to show when the application is launched for the first time. something like th:

First run: Greeting.xaml> Setting.xaml> MainPage.xaml

Normal launch goes directly to MainPage.

How can i do this?

I didn’t mean Splashscreen, I mean the page that is displayed only when the application is first launched, something like a small tutorial.

+4
source share
3 answers

"" App.xaml.cs. OnLaunched void rootFrame.Navigate(typeof(MainPage)); rootFrame.Navigate(typeof(Greeting)); .

. .  1. OnnavigatedTo void Greeting.xaml( "protected override void onna", IntelliSense ) , "async" "protected", 2. :

if (ApplicationData.Current.LocalSettings.Values.ContainsKey("isFirstLaunch"))
{
    // if that the first launch, stay, otherwise navigate to Settings.xaml
    if (!(bool)ApplicationData.Current.LocalSettings.Values["isFirstLaunch"])
    {
        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Frame.Navigate(typeof(Settings)));
    }
}
else
{
    ApplicationData.Current.LocalSettings.Values["isFirstLaunch"] = false;
}

, . , .

: : D fooobar.com/questions/1627133/...

+3

App.xaml.cs - OnLaunched:

if (rootFrame.Content == null)
{
    rootFrame.Navigate(typeof(MainPage), e.Arguments);
}

. , - :

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
    }
}

, .

, , .

+5

I just wanted the disclaimer to be accepted through MessageBox

            IPropertySet roamingProperties = ApplicationData.Current.RoamingSettings.Values;
            if (!roamingProperties.ContainsKey("DisclaimerAccepted"))
            {
                var dialog = new MessageDialog(strings.Disclaimer);
                dialog.Title = "Disclaimer";
                dialog.Commands.Clear();
                dialog.Commands.Add(new UICommand { Label = "Accept", Id = 0 });

                dialog.Commands.Add(new UICommand { Label = "Decline", Id = 1 });
                var result = await dialog.ShowAsync();
                if ((int)result.Id == 1)
                    Application.Current.Exit();
                roamingProperties["DisclaimerAccepted"] = bool.TrueString; 
            }

I placed it in App.xaml.cs inside:

if (e.PrelaunchActivated == false)
        {
            <Inside here>
            if (rootFrame.Content == null)
            {
            }
0
source

Source: https://habr.com/ru/post/1627133/


All Articles