Our problem is that our app does not require a dark mode, but the Syncfusion controls will implement their dark color palette regardless. After consulting various other threads that described the same problem, we have applied the following to no avail:
App.xaml
<Application ...>
<Application.Resources>
<themes:SyncfusionThemeDictionary x:Key="SyncfusionThemeDictionary">
<themes:SyncfusionThemeDictionary.MergedDictionaries>
<themes:LightTheme />
themes:SyncfusionThemeDictionary.MergedDictionaries>
themes:SyncfusionThemeDictionary>
<!--...other resources...-->
Application.Resources>
Application>
App.xaml.cs
public App()
{
// ...other code...
this.InitializeComponent();
this.ChangeThemeToLight();
Current.RequestedThemeChanged+=(s,a)=>
{
if(Current.UserAppTheme!=OSAppTheme.Light)
{
this.ChangeThemeToLight();
}
};
this.MainPage= newNavigationPage(newMainPage());
}
private void ChangeSyncfusionThemeToLight()
{
ICollectionmergedDictionaries =Current.Resources.MergedDictionaries;
DarkThemedarkTheme = mergedDictionaries.OfType() .FirstOrDefault();
if(darkTheme != null)
{
mergedDictionaries.Remove(darkTheme);
}
mergedDictionaries.Add(newLightTheme());
}
private void ChangeThemeToLight()
{
Current.UserAppTheme=OSAppTheme.Light;
this.ChangeSyncfusionThemeToLight();
}
MainActivity.cs
protected override void OnCreate(Bundle savedInstanceState)
{
AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
base.OnCreate(savedInstanceState);
Xamarin.Forms.Forms.Init(this, savedInstanceState);
this.LoadApplication(new App());
}
Info.plist
UIUserInterfaceStyle Light
Our goal: Having only the light mode palettes on all Syncfusion components. A workaround will suffice if this is not officially supported.
Syncfusion version: 19.3.43
Xamarin Forms: 5.0.0.2083
Hello,
The code I referenced does not enforce the dark theme, even though it should. That's why I provided it. That code doesn't work. What you see above is what I already have in my project, but the dark theme is still applied.
Looking forward to hearing from you,
Dimitris
Hello again,
Your sample works as expected on iOS. On the Android emulator, it works as expected as well. After further investigation on our part, it seems the problem specifically is centered around the MIUI OS that Xiaomi phones mainly use, which we use as our test device. It seems like they force their own dark palette on the application. I do not suppose you have a workaround for that, since it is not specifically a Syncfusion problem..
Regards,
Dimitris
Hello,
This really fixed it for us on MIUI, thank you.
Kind Regards,
Dimitris