Switching Between Light Theme and Dark Theme
26 May 20251 minute to read
Refer to the following example code to switch between light and dark themes in Syncfusion® MAUI controls.
void UpdateTheme(object sender, System.EventArgs e)
{
ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
if (mergedDictionaries != null)
{
var theme = mergedDictionaries.OfType<SyncfusionThemeResourceDictionary>().FirstOrDefault();
if (theme != null)
{
if (theme.VisualTheme is SfVisuals.MaterialDark)
{
theme.VisualTheme = SfVisuals.MaterialLight;
}
else
{
theme.VisualTheme = SfVisuals.MaterialDark;
}
}
}
}
The complete theme switch sample is available in this link.