[Bug] Accent Color and System Theme changes are not updated in Packaged WPF apps
See original GitHub issueThis 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:
- Created 3 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
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
Yes, I’m fairly certain
UISettings
is the culprit, at least on Win10 2004. I tried ModernFlyouts and callingListenToSystemColorChanges
didn’t seem to help—the settings window still didn’t react to theme changes, for example.