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

ThemeManager's OnThemeChanged work-around conflicting with other WPF internals. #923

Closed
remcoros opened this issue Jan 11, 2014 · 5 comments

Comments

@remcoros
Copy link
Contributor

I found a conflict with ThemeManager and SharedSizeGroup (or rendering in general).

See this SO question for more details: http://stackoverflow.com/questions/21061630/wpf-listbox-selecteditem-changing-twice-bug/21061804?noredirect=1#comment31671940_21061804

It seems this work-around is conflicting with other rendering procedures in WPF:

    /// <summary>
    /// Invalidates global colors and resources.
    /// Sometimes the ContextMenu is not changing the colors, so this will fix it.
    /// </summary>

I disabled this method in a custom build and my issue (on SO) goes away.

Obviously disabling this work-around is not a real fix.

Hopefully anyone with more experience of WPF internals can take a look.

@remcoros
Copy link
Contributor Author

I also noticed that without these internal calls. The theme/accent change is almost instant. Where as with OnThemeChanged enabled there is a small delay / freeze of the application when changing the theme.

@flagbug
Copy link
Member

flagbug commented Jan 11, 2014

Hm, this may also be the reason why MediaElement resets itself when changing the accent

@remcoros
Copy link
Contributor Author

with the work-around disabled, I now see old accent colors. obviously. I hope someone can come up with a solution.

@AzureKitsune
Copy link
Member

Perhaps @punker76 can chime in on this.

@remcoros
Copy link
Contributor Author

I did some trial and error on this.

Disabling line 285, fixes my issue with the ListBox (and probably also with mentioned MediaElement), while still refreshing the accent colors:

        var invalidateParameters = typeof(SystemParameters).GetMethod("InvalidateCache", BindingFlags.Static | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
        if (invalidateParameters != null)
        {
            // invalidateParameters.Invoke(null, null);
        }

This solved everything for me.

Please verify.

@remcoros remcoros mentioned this issue Jan 13, 2014
punker76 added a commit that referenced this issue Jan 14, 2014
@AzureKitsune AzureKitsune mentioned this issue Jan 14, 2014
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants