question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Accent Color and System Theme changes are not updated in Packaged WPF apps

See original GitHub issue

This could be similar to #143. But this is an entirely different case.

There was an attempt to remove the app.manifest requirement (previously a mandatory need to detect the OS version) in 2c27fba92296ff54bde425fb7d3bd1baa844eb86. Despite removing the app.manifest requirement the bug has occurred to me (and I do have app manifest)

When the app is executed as an unpackaged application, there are no problems with theme/accent changes. But when the same app is executed as a packaged (MSIX) application, the accent-color/system-theme changes are not perceived by the packaged application.

I can assure that this bug doesn’t happen when the app is unpackaged.

Workaround

I used Reflection to invoke this internal method This won’t work see https://github.com/Kinnara/ModernWpf/issues/175#issuecomment-701740907

private void ListenToSystemColorChanges()
{
    Type ColorsHelperType = Type.GetType("ModernWpf.ColorsHelper, ModernWpf");
    PropertyInfo CurrentProperty = ColorsHelperType.GetProperty("Current", BindingFlags.Static | BindingFlags.Public);
    object colorsHelperInstance = CurrentProperty.GetValue(null);
    MethodInfo ListenToSystemColorChangesMethod = ColorsHelperType.GetMethod("ListenToSystemColorChanges",
        BindingFlags.Instance | BindingFlags.NonPublic);
    ListenToSystemColorChangesMethod.Invoke(colorsHelperInstance, null);
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ShankarBUScommented, Oct 4, 2020

Hey @Kinnara, a suggestion

While committing a fix regarding a issue, you can use the Fix\Fixed\Fixes #{issue-no} {Issue Title} format to automatically close those issues while committing.

It saves me a lot of time. Would be helpful for you maintaining a repo efficiently

1reaction
Kinnaracommented, Sep 30, 2020

Yes, I’m fairly certain UISettings is the culprit, at least on Win10 2004. I tried ModernFlyouts and calling ListenToSystemColorChanges didn’t seem to help—the settings window still didn’t react to theme changes, for example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change accent color stopped working in UI for WPF
I've checked and noticed that the problem is with the MaterialAssist, that is not using the color set in the AccentColor of the...
Read more >
How to change SystemAccentColor at runtime (UWP)?
I want to override the StaticResource SystemAccentColor (the one that is user defined on their system) in order to update the app with...
Read more >
WPF-UI 2.0.2
Allows to change the application color accents. Watcher, Wpf.Ui.Appearance, Listens for changes in system parameters, then switches theme with Appearance.Theme.
Read more >
XAML theme resources - Windows apps
Theme resources in XAML are a set of resources that apply different values depending on which system theme is active.
Read more >
5 Steps to Getting Started With Material Design In XAML
Step 1: Create a WPF Project ... From Visual Studio, select File > New > Project. Then, under the Installed category, expand either...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found