示例#1
0
        private async Task OnLaunchOrActivated(IActivatedEventArgs e)
        {
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Load state from previously terminated application
                    await SuspensionManager.RestoreAsync();

#if DEBUG
                    await MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate");
#endif
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e is LaunchActivatedEventArgs lauchActivatedEventArgs && rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage10), lauchActivatedEventArgs.Arguments);
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }