An empty page that can be used on its own or navigated to within a Frame.
Наследование: Windows.UI.Xaml.Controls.Frame
Пример #1
0
        private async Task InitializeAsync(IActivatedEventArgs e, bool preLaunchActivated = false)
        {
            try
            {
#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //this.DebugSettings.EnableFrameRateCounter = true;
                    //this.DebugSettings.EnableRedrawRegions = true;
                    //this.DebugSettings.IsOverdrawHeatMapEnabled = true;
                    //this.DebugSettings.IsBindingTracingEnabled = true;
                    //this.DebugSettings.IsTextPerformanceVisualizationEnabled = true;
                }

                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    this.DebugSettings.BindingFailed += DebugSettings_BindingFailed;
                }
#endif

                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    // No need to run any of this logic if the app is already running

                    // Ensure unobserved task exceptions (unawaited async methods returning Task or Task<T>) are handled
                    TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

                    // Determine if the app is a new instance or being restored after app suspension
                    if (e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser || e.PreviousExecutionState == ApplicationExecutionState.NotRunning)
                    {
                        await Platform.Current.AppInitializingAsync(InitializationModes.New);
                    }
                    else
                    {
                        await Platform.Current.AppInitializingAsync(InitializationModes.Restore);
                    }
                }



                Frame rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new ApplicationFrame();

                    // Associate the frame with a SuspensionManager key
                    SuspensionManager.RegisterFrame(rootFrame, "RootFrame");

                    // Set the default language
                    rootFrame.Language          = Windows.Globalization.ApplicationLanguages.Languages[0];
                    rootFrame.NavigationFailed += OnNavigationFailed;

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

                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        try
                        {
                            // Restore the saved session state only when appropriate
                            await SuspensionManager.RestoreAsync();
                        }
                        catch (SuspensionManagerException)
                        {
                            // Something went wrong restoring state.
                            // Assume there is no state and continue
                        }
                    }
                }

                if (preLaunchActivated == false)
                {
                    // Manage activation and process arguments
                    Platform.Current.Navigation.HandleActivation(e, rootFrame);

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

                    ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 200));
                }
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogErrorFatal(ex, "Error during App InitializeAsync(e)");
                throw ex;
            }
        }
Пример #2
0
        private async Task InitializeAsync(IActivatedEventArgs e, bool preLaunchActivated = false)
        {
            try
            {
#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //this.DebugSettings.EnableFrameRateCounter = true;
                    //this.DebugSettings.EnableRedrawRegions = true;
                    //this.DebugSettings.IsOverdrawHeatMapEnabled = true;
                    //this.DebugSettings.IsBindingTracingEnabled = true;
                    //this.DebugSettings.IsTextPerformanceVisualizationEnabled = true;
                }

                if(e.PreviousExecutionState != ApplicationExecutionState.Running)
                    this.DebugSettings.BindingFailed += DebugSettings_BindingFailed;
#endif

                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    // No need to run any of this logic if the app is already running

                    // Ensure unobserved task exceptions (unawaited async methods returning Task or Task<T>) are handled
                    TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

                    // Determine if the app is a new instance or being restored after app suspension
                    if (e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser || e.PreviousExecutionState == ApplicationExecutionState.NotRunning)
                        await Platform.Current.AppInitializingAsync(InitializationModes.New);
                    else
                        await Platform.Current.AppInitializingAsync(InitializationModes.Restore);
                }

                //Turn off Title Safe Area overscan adjustment
                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationViewBoundsMode") && Platform.DeviceFamily == DeviceFamily.Xbox)
                {
                    var AppView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
                    AppView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
                }

                ////Turn of scaling, if app is not designed at 540p (Xbox One default scaling is 200% for XAML, 150% for Web Programming model apps)
                //if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(
                //        "Windows.UI.ViewManagement.ApplicationViewScaling"))
                //{
                //    Windows.UI.ViewManagement.ApplicationViewScaling.TrySetDisableLayoutScaling(true);
                //}

                Frame rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new ApplicationFrame();

                    // Associate the frame with a SuspensionManager key                                
                    SuspensionManager.RegisterFrame(rootFrame, "RootFrame");

                    // Set the default language
                    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;

                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        try
                        {
                            // Restore the saved session state only when appropriate
                            await SuspensionManager.RestoreAsync();
                        }
                        catch (SuspensionManagerException)
                        {
                            // Something went wrong restoring state.
                            // Assume there is no state and continue
                        }
                    }
                }

                if (preLaunchActivated == false)
                {
                    // Manage activation and process arguments
                    Platform.Current.Navigation.HandleActivation(e, rootFrame);
                    
                    // Ensure the current window is active
                    Window.Current.Activate();

                    ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 200));
                }
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogErrorFatal(ex, "Error during App InitializeAsync(e)");
                throw ex;
            }
        }