© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago
Rhemsuda

Maui TitleBar transparency & changing Caption Control colors?

Hey folks, I'm having a hell of a time updating the Windows Titlebar using Maui and Windows API.

I've tried probably everything I can think of but this is just a massive game of whack-a-mole.

I have this code that I've been able to use to get rid of the titlebar, allow the background and contents to extend into the titlebar, however I cannot for the life of me change the colors of the Background.

I cannot use the AppWindow.TitleBar colors as when I do this, I'm unable to change the transparency of the titlebar, and when I set ExtendsContentIntoTitleBar to false, I get two title bars layered on top of one another (wut?).

So the closest I've been able to get is to remove the titlebar using the OverlappedPresenter and set the titlebar to some blank grid to get rid of the extra space on the side.

My code is as follows:

builder.ConfigureLifecycleEvents(events =>
{
    events.AddWindows(wndLifeCycleBuilder =>
    {
        wndLifeCycleBuilder.OnWindowCreated(window =>
        {
            window.ExtendsContentIntoTitleBar = true;
            IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
            WindowId win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
            AppWindow winuiAppWindow = AppWindow.GetFromWindowId(win32WindowsId);
    
            if (winuiAppWindow.Presenter is OverlappedPresenter p)
            {
                p.SetBorderAndTitleBar(false, false);
            }
            
            window.SetTitleBar(new Microsoft.UI.Xaml.Controls.Grid());
        });
    });
});
builder.ConfigureLifecycleEvents(events =>
{
    events.AddWindows(wndLifeCycleBuilder =>
    {
        wndLifeCycleBuilder.OnWindowCreated(window =>
        {
            window.ExtendsContentIntoTitleBar = true;
            IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
            WindowId win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
            AppWindow winuiAppWindow = AppWindow.GetFromWindowId(win32WindowsId);
    
            if (winuiAppWindow.Presenter is OverlappedPresenter p)
            {
                p.SetBorderAndTitleBar(false, false);
            }
            
            window.SetTitleBar(new Microsoft.UI.Xaml.Controls.Grid());
        });
    });
});


My title bar currently looks like image 1, where I need it to look like image 2.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Tilemap control in MAUI
C#CC# / help
2y ago
❔ DataGrid control in Maui
C#CC# / help
3y ago
❔ WinUi TitleBar
C#CC# / help
3y ago
Maui issues after changing namespace
C#CC# / help
2y ago