wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

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

Open SamKr opened this issue 1 year ago • 0 comments

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)
{
    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;
    }

    ApplicationAccentColorManager.Apply(Colors.Red, CurrentApplicationTheme);
}

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

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 avatar Feb 20 '24 10:02 SamKr