private async void CreateNewView(object sender, RoutedEventArgs e) { var newView = await ViewHelper.MakeSecondaryViewFromUIThread(() => { var frame = new TestFrame(typeof(MainPage)); frame.NavigateWithoutAnimation(typeof(RevealScenarios)); Window secondaryWindow = Window.Current; secondaryWindow.Content = frame; ApplicationView.GetForCurrentView().Consolidated += (consolidatedSender, args) => { secondaryWindow.Close(); }; }); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { _isRootCreated = false; #if BUILD_WINDOWS AppendResourceToMergedDictionaries("DEPControls.xaml"); #endif #if FEATURE_SCROLLER_ENABLED // Tracked by Issue 1043 AppendResourceToMergedDictionaries("AdditionalStyles.xaml"); #endif // For test purposes, add styles that disable long animations. DisableLongAnimations = true; #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = false; this.DebugSettings.BindingFailed += (object sender, BindingFailedEventArgs args) => { Debug.WriteLine(args.Message); }; } #endif MaterialHelperTestApi.IgnoreAreEffectsFast = false; GC.Collect(); e.SplashScreen.Dismissed += SplashScreen_Dismissed; Action createRoot = () => { var rootFrame = Window.Current.Content as TestFrame; // 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 TestFrame(typeof(MainPage)); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } Window.Current.Content = rootFrame; rootFrame.NavigateWithoutAnimation(typeof(MainPage)); } _isRootCreated = true; if (_isSplashScreenDismissed) { SplashScreenDismissedAndRootCreated(); } }; // To exercise a couple different ways of setting up the tree, when run in APPX test mode then delay-attach the root. if (e.Arguments.Length == 0) { createRoot(); } else { var uiDispatcher = Window.Current.Dispatcher; System.Threading.Tasks.Task.Delay(2000).ContinueWith( (t) => { var ignored = uiDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { createRoot(); }); }); } Window.Current.Activated += OnWindowActivated; // Ensure the current window is active Window.Current.Activate(); // If there are multiple arguments we assume we're being launched as a TAEF AppX test, so start up the TAEF dispatcher. if (e.Arguments.Length > 0) { // By default Verify throws exception on errors and exceptions cause TAEF AppX tests to fail in non-graceful ways // (we get the test failure and then TE keeps trying to talk to the crashing process so we get "TE session timed out" errors too). // Just disable exceptions in this scenario. Verify.DisableVerifyFailureExceptions = true; Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); } }