Hello,
Ideally I want my app to follow the system theme setting. The best scenario is that when the user changes to Light or Dark theme from device setting, I want my app to adapt to this. I just found out (unless I am missing something) that MAUI is not doing this yet.
This issue is a known issue in GitHub, see [regression/7.0.0] Application.Current.RequestedThemeChanged event only raises once #8236.
Short of the ideal (following system theme), I don't mind providing a theme toggle in my app setting so that the user can choose as required. This is better than fixing the theme (because some users like a dark theme, say, for night vision, or to save battery if their device display technology allows it).
You could manually switch between light or dark themes for the program, see the following code.
private void ChangeThemeBtn_Clicked(object sender, EventArgs e)
{
if (Application.Current.UserAppTheme == AppTheme.Dark)
{
Application.Current.UserAppTheme = AppTheme.Light;
}
else
{
Application.Current.UserAppTheme = AppTheme.Dark;
}
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.