/// <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(); }