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

ApplicationAccentColorManager.Apply not applying properly on all controls, only on mouseover. #965

Closed
SamKr opened this issue Feb 20, 2024 · 1 comment · Fixed by #994
Closed
Labels
bug Something isn't working locked-due-to-inactivity

Comments

@SamKr
Copy link
Contributor

SamKr commented Feb 20, 2024

Describe the bug

When applying an application accent color, it doesn't get properly set on all controls, only mouseover works.

To Reproduce

To reproduce, I've used the Wpf.Ui.Demo.Mvvm project (latest version), and modified SettingsViewModel as such:

[RelayCommand]
private void OnChangeTheme(string parameter)
{
    ApplicationAccentColorManager.Apply(Colors.Red, CurrentApplicationTheme);

    switch (parameter)
    {
        case "theme_light":
            if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Light)
                break;

            Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Light);
            CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Light;

            break;

        default:
            if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Dark)
                break;

            Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Dark);
            CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Dark;

            break;
    }
}

Note the ApplicationAccentColorManager.Apply(Colors.Red, CurrentApplicationTheme);.

I've added a toggleswitch to SettingsPage.xaml to showcase the problem. Please refer to the gif in the 'Screenshots' section for a visual representation.

Now when I toggle between light and dark theme, nothing changes. But when you hover the mouse over a control, the color appears.

When checking the ApplicationAccentColorManager.PrimaryAccent, ApplicationAccentColorManager.SecondaryAccent etc properties, they all have the correct values. The same problem occurs when using ApplicationAccentColorManager.Apply(Color systemAccent, Color primaryAccent, Color secondaryAccent, Color tertiaryAccent).

So it looks to be in the controls not adopting the new accent colors.

Expected behavior

The controls should change accent colors when executing ApplicationAccentColorManager.Apply.

Screenshots

WindowsSandboxClient_C0MjAgZbF8

OS version

Windows 11

.NET version

.NET 8

WPF-UI NuGet version

Cloned the latest main branch.

Additional context

No response

@SamKr SamKr added the bug Something isn't working label Feb 20, 2024
@SamKr
Copy link
Contributor Author

SamKr commented Mar 13, 2024

Update

A working implementation is to set the:

ApplicationAccentColorManager.Apply(Colors.Red, CurrentApplicationTheme);

Right before you set the theme (manual or through a system change). If it's applied afterwards, it gets ignored. I've updated the code in my example accordingly.

This in conjunction with the linked PR should have the accentcolors working as expected.

@pomianowski pomianowski linked a pull request Mar 13, 2024 that will close this issue
7 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working locked-due-to-inactivity
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants