Page.BackgroundColor and others not reacting to changes in Application.Current.UserAppTheme
See original GitHub issueDescription
Some things are not updated properly when the UserAppTheme is changed, most notably the Page.BackgroundColor. There are also other things with the same issue, such as the view that pops up when you want to select something from a picker.
This issue is probably related to #6092
Steps to Reproduce
- Create a new .MAUI project
- Add this to MainPage.xaml
<Picker HorizontalOptions="Center"
x:Name="picker">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Just</x:String>
<x:String>some</x:String>
<x:String>random</x:String>
<x:String>text</x:String>
</x:Array>
</Picker.ItemsSource>
</Picker>
- Change the implementation of OnCounterClicked in MainPage.xaml.cs to this:
private void OnCounterClicked(object sender, EventArgs e)
{
if (picker.SelectedIndex < 0)
{
picker.SelectedIndex = 0;
}
Button button = (Button)sender;
switch (Application.Current.UserAppTheme)
{
case AppTheme.Unspecified:
Application.Current.UserAppTheme = AppTheme.Light;
button.Text = "Light";
break;
case AppTheme.Light:
Application.Current.UserAppTheme = AppTheme.Dark;
button.Text = "Dark";
break;
case AppTheme.Dark:
Application.Current.UserAppTheme = AppTheme.Unspecified;
button.Text = "Unspecified";
break;
}
}
- Click on the button to switch through themes. After a theme switch, select something from the picker.
Version with bug
Release Candidate 2 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Windows 10, Android 12, Android 7
Did you find any workaround?
No response
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Respond to system theme changes - .NET MAUI
NET MAUI app can respond to operating system theme changes by using the AppThemeBinding markup extension, and the SetAppThemeColor and ...
Read more >Respond to system theme changes in Xamarin.Forms ...
Xamarin.Forms applications can respond to operating system theme changes by using the OnAppTheme type, and the DynamicResource markup ...
Read more >Statusbar theme only changes after restarting app
My apps statusbar does not seem to react to android system theme changes while the app is loaded. The statusbar only updates after...
Read more >Dynamic App Themes in Xamarin.Forms - YouTube
WT.mc_id=friends-0000-jamont * App Theme Bindings ... They are NOT officially affiliated or endorsed by Microsoft (my employer) in any way.
Read more >Implement dark theme
On this page; Support dark theme in your app. Themes and styles; Change themes in-app. Force Dark. Disable Force Dark on a view....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Does work for me on macOS with iOS, Android and MacCatalyst in VS when using the code from the issue, but doesn’t work when the OS does change the Theme.
My VS info:
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.