Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Title Bar Colors not working after migrating to .NET 8 #19787

Closed
stephansum opened this issue Jan 9, 2024 · 4 comments
Closed

Custom Title Bar Colors not working after migrating to .NET 8 #19787

stephansum opened this issue Jan 9, 2024 · 4 comments
Labels
platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working

Comments

@stephansum
Copy link

Description

With .NET 7 i was able to customize the title bar colors for my windows maui application like this:

<maui:MauiWinUIApplication.Resources>
    <ResourceDictionary>
        <SolidColorBrush x:Key="WindowCaptionBackground" Color="#0c0c0c" />
        <SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Black" />
        <SolidColorBrush x:Key="WindowCaptionForeground" Color="#f2f2f2" />
        <SolidColorBrush x:Key="WindowCaptionForegroundDisabled" Color="White" />
    </ResourceDictionary>
</maui:MauiWinUIApplication.Resources>

After migrating to .NET 8 it seems like these dictionairy keys are no longer considered. I am just getting the default title bar appearance.

Note that iam using ExtendsContentIntoTitleBar = false in my scenario. When i try go with a fully customized title bar using window.ExtendsContentIntoTitleBar = true, i get a different problem already described here: #18773

I also tried to color my title bar using:

<DataTemplate x:Key="MauiAppTitleBarTemplate">
    <Grid
        Canvas.ZIndex="1" 
        Background="#0c0c0c"
        VerticalAlignment="Stretch"
        Margin="0,0,0,0">
        <TextBlock 
            VerticalAlignment="Center"
            HorizontalAlignment="Left"
            Text="My App" 
            Foreground="#f2f2f2"
            FontWeight="Bold"/>
    </Grid>
</DataTemplate>

but i didnt find a way to change the foreground color of the system buttons (close, minimize etc)

Any tips/workarounds are appreciated until this is resolved.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.101

Affected platforms

Windows

Affected platform versions

net8.0-windows10.0.19041.0

Did you find any workaround?

No response

Relevant log output

No response

@stephansum stephansum added the t/bug Something isn't working label Jan 9, 2024
@Foda
Copy link
Member

Foda commented Jan 9, 2024

Hello! We have plans to provide more robust APIs for titlebar customization in the next major release, but for now you should be able to modify the titlebar foreground color by using:

appWindow.TitleBar.ButtonForegroundColor

@samhouts samhouts added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Jan 10, 2024
@Yu-Core
Copy link

Yu-Core commented Jan 11, 2024

@stephansum
I am using Windows 10 (.NET 8), appWindow.TitleBar.ButtonForegroundColor is supported。

@stephansum
Copy link
Author

@Yu-Core

appWindow.TitleBar.ButtonForegroundColor is indeed supported whereas
appWindow.TitleBar.ForegroundColor is not

Docs could be more clear on that. Anyway - thank you for pointing that out - helped me a lot !

@PureWeen PureWeen closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants