Setting Application.Current.UserAppTheme leads to crash #28432
Unanswered
FALKENSTEIN-VIA
asked this question in
Q&A
Replies: 1 comment
-
I've seen a scary post where one was deleting from and adding to Application.Current.Resources.MergedDictionaries. This can be disastrous if you were clearing other ResourceDictionaries and/or your styles momentary saw a state of 0 resource dictionaries. I was inspired by Programming With Chris' YouTube video on Runtime Thems in .Net Maui!. And I wrote a StackOverflow answer based on it where you update the DynamicResource entries. See https://stackoverflow.com/questions/78833650/maui-dynamic-ui-changes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've implemented two resource dictionaries for my theme (LightTheme.xaml / DarkTheme.xaml).
At runtime, I switch the theme in Application.Current.Resources.MergedDictionaries.
This is done in my ClassLibrary in a static ThemeManager class.
As long as I don't set Application.Current.UserAppTheme to AppTheme.Light / AppTheme.Dark there, everything works fine!
But if I do, my application immediately freezes!
I've tried everything (lock, dispatcher, main thread), but nothing helps.
What could be the cause?
Is it even allowed to set UserAppTheme when exchanging the (Theme) ResourceDictionaries?
Unfortunately I can't debug it, the fun stops at the line with the breakpoint where I try!
Beta Was this translation helpful? Give feedback.
All reactions