Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,21 @@ void SetCurrent(
}

var windowManager = modalContext.GetNavigationRootManager();
var platform = newPage.ToPlatform(modalContext);
_waitingForIncomingPage = platform.OnLoaded(() => completedCallback?.Invoke());
windowManager.Connect(platform);
Container.AddPage(windowManager.RootView);
if (windowManager is not null)
{
// Set the titlebar on the new navigation root
if (previousPage is not null &&
previousPage.GetParentWindow() is Window window &&
window.TitleBar is TitleBar titlebar)
{
windowManager.SetTitleBar(titlebar, modalContext);
}

var platform = newPage.ToPlatform(modalContext);
_waitingForIncomingPage = platform.OnLoaded(() => completedCallback?.Invoke());
windowManager.Connect(platform);
Container.AddPage(windowManager.RootView);
}
}
// popping modal
else
Expand All @@ -135,6 +146,14 @@ void SetCurrent(
wrv.SetTitleBarVisibility(UI.Xaml.Visibility.Visible);
}

// Restore the titlebar
if (previousPage is not null &&
previousPage.GetParentWindow() is Window window &&
window.TitleBar is TitleBar titlebar)
{
windowManager.SetTitleBar(titlebar, context);
}

var platform = newPage.ToPlatform();
_waitingForIncomingPage = platform.OnLoaded(() => completedCallback?.Invoke());
Container.AddPage(windowManager.RootView);
Expand Down
13 changes: 10 additions & 3 deletions src/Core/src/Platform/Windows/WindowRootView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ internal void SetTitleBar(ITitleBar? titlebar, IMauiContext? mauiContext)

if (_titleBar is null || mauiContext is null)
{
UpdateBackgroundColorForButtons();
return;
}

Expand Down Expand Up @@ -506,10 +507,16 @@ private void TitlebarPropChanged_PropertyChanged(object? sender, PropertyChanged

private void UpdateBackgroundColorForButtons()
{
if (NavigationViewControl?.ButtonHolderGrid is not null &&
_titleBar?.Background is SolidPaint bg)
if (NavigationViewControl?.ButtonHolderGrid is not null)
{
NavigationViewControl.ButtonHolderGrid.Background = new SolidColorBrush(bg.Color.ToWindowsColor());
if (_titleBar?.Background is SolidPaint bg)
{
NavigationViewControl.ButtonHolderGrid.Background = new SolidColorBrush(bg.Color.ToWindowsColor());
}
else
{
NavigationViewControl.ButtonHolderGrid.Background = new SolidColorBrush(UI.Colors.Transparent);
}
}
}

Expand Down