Example #1
0
        protected void InternalLaunch(ILaunchActivatedEventArgs e)
        {
            if (e.PreviousExecutionState != ApplicationExecutionState.Running)
            {
                InitializeFrame(e);
            }

            //adding a default navigation service
            if (!NavigationServices.IsRegistered("Default"))
            {
                NavigationServices.Register("Default", WindowWrapper.Current().NavigationService);
            }

            // okay, now handle launch
            switch (e.PreviousExecutionState)
            {
            case ApplicationExecutionState.Terminated:
            {
                OnStart(StartKind.Launch, e);

                SubscribeBackButton();

                break;
            }

            case ApplicationExecutionState.ClosedByUser:
            case ApplicationExecutionState.NotRunning:
                // launch if not restored
                OnStart(StartKind.Launch, e);

                SubscribeBackButton();

                break;

            case ApplicationExecutionState.Running:
                OnStart(StartKind.Activate, e);
                break;

            default:
            {
                // launch if not restored
                OnStart(StartKind.Launch, e);
                break;
            }
            }
        }
Example #2
0
        protected void InitializeFrame(IActivatedEventArgs e)
        {
            // allow the user to do things, even when restoring
            OnInitialize(e);

            // create the default frame only if there's nothing already there
            // if it is not null, by the way, then the developer injected something & they win
            if (Window.Current.Content == null)
            {
                // build the default frame
                var frame             = CreateRootFrame(e);
                var navigationService = new NavigationService(frame);
                navigationService.IsBackButtonEnabled = IsBackButtonEnabled;
                Window.Current.Content = navigationService.Frame;
                WindowWrapper.Current().NavigationService = navigationService;
            }

            Window.Current.Activate();
        }
Example #3
0
        /// <summary>
        /// This handles all the prelimimary stuff unique to Activated before calling OnStartAsync()
        /// This is private because it is a specialized prelude to OnStartAsync().
        /// OnStartAsync will not be called if state restore is determined.
        /// </summary>
        protected void InternalActivatedAsync(IActivatedEventArgs e)
        {
            // sometimes activate requires a frame to be built
            if (Window.Current.Content == null)
            {
                InitializeFrame(e);
            }

            //adding a default navigation service
            if (!NavigationServices.IsRegistered("Default"))
            {
                NavigationServices.Register("Default", WindowWrapper.Current().NavigationService);
            }

            // onstart is shared with activate and launch
            OnStart(StartKind.Activate, e);

            // ensure active (this will hide any custom splashscreen)
            Window.Current.Activate();
        }