How to detect Xamarin Forms System Theme Change from Light to Dark ??
I have detected the App Theme change but how can I detect the change of whole operating/device theme change ?
I am using :
Application.Current.RequestedThemeChanged
How to detect Xamarin Forms System Theme Change from Light to Dark ??
I have detected the App Theme change but how can I detect the change of whole operating/device theme change ?
I am using :
Application.Current.RequestedThemeChanged
As mentionned in the docs react to theme changes you can achieve it by handeling the event Application.RequestedThemeChanged
Application.Current.RequestedThemeChanged += (s, a) => {
switch(a.RequestedTheme) {
case OSAppTheme.Dark:
//do something
break;
case OSAppTheme.Light:
//do something
break;
case OSAppTheme.Unspecified:
//do something
break;
}
};
Additional flag in order to work for Android
[Activity(..., ConfigurationChanges = ConfigChanges.UiMode...
To respond to theme changes on Android you must include the ConfigChanges.UiMode flag in the Activity attribute of your MainActivity class.