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

TrayIcon content does not react to DynamicResource changes #19

Closed
NikasZalias opened this issue Jan 10, 2020 · 14 comments · Fixed by #117
Closed

TrayIcon content does not react to DynamicResource changes #19

NikasZalias opened this issue Jan 10, 2020 · 14 comments · Fixed by #117
Assignees
Labels
Bug Bug or Bug fixes
Milestone

Comments

@NikasZalias
Copy link

How can I make my TrayIcon react to Theme changes? When I change my app theme from light to dark or vice versa, tray icon stays the same until I restart app. Why is it like that?

@NikasZalias
Copy link
Author

@punker76

@angelwzr
Copy link

I'm interested in finding out what causes this behavior too.
@NikasZalias were you able to fix this after all?

@sirdoombox
Copy link

I'm also having similar issues using MahApps styles for the ContextMenu and MenuItem, for some reason only the foreground hover brush is changed when you change themes, but the foreground/background is not.

@Symbai
Copy link

Symbai commented Sep 22, 2020

Same

@CoelWu
Copy link

CoelWu commented Apr 13, 2021

Same here, I'm setting the MenuItem's header to a dynamicResource, it just does not change when the dynamicResource changes.

@CoelWu
Copy link

CoelWu commented Apr 13, 2021

@punker76

@Lakritzator
Copy link
Collaborator

Maybe someone can make a minimalistic example project for this?

@Erapchu
Copy link

Erapchu commented Dec 3, 2021

As a solution: subscribe to TrayContextMenuOpen event of TaskbarIcon, and call UpdateDefaultStyle for context menu that required to be updated. Or call UpdateDefaultStyle when theme changed.

@Erapchu
Copy link

Erapchu commented Dec 3, 2021

Popup control that host context menu or other controls can't correctly get dynamic resources changes from Application merged resource I guess. Popup on the same visual level where Application exists.

@DarkPro1337
Copy link
Contributor

As a solution: subscribe to TrayContextMenuOpen event of TaskbarIcon, and call UpdateDefaultStyle for context menu that required to be updated. Or call UpdateDefaultStyle when theme changed.

Working as intended now, much thanks!

@Erapchu
Copy link

Erapchu commented Jul 5, 2022

Oh, as an example:

https://github.com/Erapchu/PasswordManager/blob/master/PasswordManager/Views/TrayIcon.xaml.cs

@Lakritzator
Copy link
Collaborator

I need to look into this again, I am also faced with the issue, so maybe I can add something to support a style update.

Btw. example link mentioned above moved to here: https://github.com/Erapchu/SinglePass.WPF/blob/master/SinglePass.WPF/Views/TrayIcon.xaml.cs

@Lakritzator Lakritzator self-assigned this Sep 5, 2022
@Erapchu
Copy link

Erapchu commented Sep 5, 2022

I renamed repo, thanks @Lakritzator
Want to leave this solution here, if anyone need it

private void TaskbarIcon_TrayContextMenuOpen(object sender, RoutedEventArgs e)
{
    // To apply DynamicResource changes
    TrayIconContextMenu?.UpdateDefaultStyle();
}

@punker76 punker76 added the Bug Bug or Bug fixes label Oct 5, 2024
@punker76 punker76 added this to the 2.0.0 milestone Oct 5, 2024
@punker76
Copy link
Collaborator

punker76 commented Oct 5, 2024

@NikasZalias This should be fixed now with #117 by using @Erapchu solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants