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

Using Mica\Acrylic backdrop with TintColor has problem with Dark theme #9286

Open
ghost1372 opened this issue Jan 26, 2024 · 0 comments
Open
Labels
area-Materials Reveal, Acrylic, lighting, etc. bug Something isn't working team-Rendering Issue for the Rendering team

Comments

@ghost1372
Copy link
Contributor

Describe the bug

i am using Mica or Acrylic Backdrop with a TintColor, this is my Mica Backdrop class

public sealed class MicaSystemBackdrop : SystemBackdrop
{
    public readonly MicaKind Kind;
    private MicaController micaController;

    public SystemBackdropConfiguration BackdropConfiguration { get; private set; }

    private Color tintColor;
    public Color TintColor
    {
        get { return tintColor; }
        set
        {
            tintColor = value;
            if (micaController != null)
            {
                micaController.TintColor = value;
            }
        }
    }

    public MicaSystemBackdrop(MicaKind micaKind)
    {
        Kind = micaKind;
    }
    protected override void OnTargetConnected(ICompositionSupportsSystemBackdrop connectedTarget, XamlRoot xamlRoot)
    {
        base.OnTargetConnected(connectedTarget, xamlRoot);

        micaController = new MicaController() { Kind = this.Kind };
        micaController.AddSystemBackdropTarget(connectedTarget);
        BackdropConfiguration = GetDefaultSystemBackdropConfiguration(connectedTarget, xamlRoot);
        micaController.SetSystemBackdropConfiguration(BackdropConfiguration);
    }

    protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop disconnectedTarget)
    {
        base.OnTargetDisconnected(disconnectedTarget);

        if (micaController is not null)
        {
            micaController.RemoveSystemBackdropTarget(disconnectedTarget);
            micaController = null;
        }
    }
}

When my app runs, i set Default TintColor like this:

TintColor = new MicaController().TintColor;

if my app start with a Dark Theme, i get this:
image

if, i disable TintColor (commenting TintColor code) and i start app again, you can see that dark theme is load correctly (without tintColor):
image

Steps to reproduce the bug

I tried the following code, But it had no effect

protected override void OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot)
    {
        if (target != null)
        {
            var config = GetDefaultSystemBackdropConfiguration(target, xamlRoot);
            micaController.SetSystemBackdropConfiguration(config);
        }
    }

Expected behavior

TintColor should be loaded correctly with Light/Dark Theme

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.4: 1.4.231219000

Windows version

Windows 11 (22H2): Build 22621

Additional context

this is my sample app, run app, change application theme to Dark, and run app again.
App18.zip

@ghost1372 ghost1372 added the bug Something isn't working label Jan 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 26, 2024
@codendone codendone added area-Materials Reveal, Acrylic, lighting, etc. team-Rendering Issue for the Rendering team and removed needs-triage Issue needs to be triaged by the area owners labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Materials Reveal, Acrylic, lighting, etc. bug Something isn't working team-Rendering Issue for the Rendering team
Projects
None yet
Development

No branches or pull requests

2 participants