public async Task PushingPageWithBackgroundStacksAndUnStacksCorrectly(bool useColor) { SetupBuilder(); var navPage = new NavigationPage(new ContentPage()); await CreateHandlerAndAddToWindow <IWindowHandler>(new Window(navPage), async (handler) => { var windowRootViewContainer = (WPanel)handler.PlatformView.Content; ContentPage backgroundColorContentPage = new ContentPage(); if (useColor) { backgroundColorContentPage.BackgroundColor = Colors.Purple; } else { backgroundColorContentPage.Background = SolidColorBrush.Purple; } await navPage.CurrentPage.Navigation.PushModalAsync(backgroundColorContentPage); var modalRootView = backgroundColorContentPage.FindMauiContext().GetNavigationRootManager().RootView; var rootPageRootView = navPage.FindMauiContext().GetNavigationRootManager().RootView; Assert.Equal(1, windowRootViewContainer.Children.IndexOf(modalRootView)); Assert.Equal(0, windowRootViewContainer.Children.IndexOf(rootPageRootView)); await navPage.CurrentPage.Navigation.PopModalAsync(); Assert.Equal(0, windowRootViewContainer.Children.IndexOf(rootPageRootView)); Assert.DoesNotContain(modalRootView, windowRootViewContainer.Children); }); }