Disabling Dark Mode for Syncfusion Components

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


7 Replies

SS Suganya Sethuraman Syncfusion Team October 12, 2021 01:11 PM UTC

Hi Dimitris,

Greetings from Syncfusion.

We have analyzed your query. We recommend that you use the light theme in the app xaml page, as shown in the code you provided.

Please let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 



DZ Dimitris Zeimpekakis October 12, 2021 01:36 PM UTC

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



SS Suganya Sethuraman Syncfusion Team October 13, 2021 12:01 PM UTC

Hi Dimitris,

We would like to let you know that Syncfusion controls are not depends on device theme. But still if you need forced to apply light theme to Syncfusion controls. We have prepared sample using LightTheme and device theme is Dark.

Please have a sample and video for your reference,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/LightThemeSample275880057

Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ThemeCheck600872259

Could you please provide more information, such as which Syncfusion controls are used in your application? and also provide the simple sample to check our side. This will help us to investigate further and provide the better solution at earliest.

Regards,
Suganya Sethuraman.
 



DZ Dimitris Zeimpekakis October 15, 2021 07:54 AM UTC

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



SS Suganya Sethuraman Syncfusion Team October 18, 2021 07:52 AM UTC

Hi Dimitris,

Thanks for the update.

We recommend that you use the following workaround to meet your requirements. Please refer the following link,

Link:
android - Detect dark mode in miui (xiaomi) - Stack Overflow

Please check and let us know if you have any concerns.


Regards,
Suganya Sethuraman.
 



DZ Dimitris Zeimpekakis October 20, 2021 10:51 AM UTC

Hello,


This really fixed it for us on MIUI, thank you.


Kind Regards,

Dimitris



SS Suganya Sethuraman Syncfusion Team October 21, 2021 05:59 AM UTC

Hi Dimitris,

Thanks for the update.

We are glad that your issue is resolved. Please let us know if you require any further assistance.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon