コード例 #1
0
        /// <summary>Creates the application's root frame and loads the first page if needed.
        /// Also calls <see cref="OnInitializedAsync"/> when the application is instantiated the first time. </summary>
        /// <param name="executionState">The application execution state. </param>
        /// <returns>The task. </returns>
        protected async Task InitializeFrameAsync(ApplicationExecutionState executionState)
        {
            var rootFrame = Window.Current.Content as MtFrame;

            if (rootFrame == null)
            {
                rootFrame = CreateFrame();

                MtSuspensionManager.RegisterFrame(rootFrame, "AppFrame");
                if (executionState == ApplicationExecutionState.Terminated)
                {
                    await RestoreStateAsync();
                }

                var task = OnInitializedAsync(rootFrame, executionState);
                if (task != null)
                {
                    await task;
                }

                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Initialize(StartPageType);
            }

            Window.Current.Activate();
        }
コード例 #2
0
        /// <summary>Creates the application's root frame and loads the first page if needed.
        /// Also calls <see cref="OnInitializedAsync"/> when the application is instantiated the first time. </summary>
        /// <param name="executionState">The application execution state. </param>
        /// <returns>The task. </returns>
        protected async Task InitializeFrameAsync(ApplicationExecutionState executionState)
        {
            if (Window.Current.Content == null)
            {
                WindowContent = CreateWindowContentElement();
                RootFrame     = GetFrame(WindowContent);

                MtSuspensionManager.RegisterFrame(RootFrame, "AppFrame");
                if (executionState == ApplicationExecutionState.Terminated)
                {
                    await RestoreStateAsync();
                }

                var task = OnInitializedAsync(RootFrame, executionState);
                if (task != null)
                {
                    await task;
                }

                Window.Current.Content = WindowContent;
            }
            else
            {
                RootFrame = GetFrame(Window.Current.Content);
            }

            if (RootFrame.Content == null)
            {
                RootFrame.Initialize(StartPageType);
            }

            Window.Current.Activate();
        }