1.1 KiB
1.1 KiB
layout | title | description | platform | control | documentation |
---|---|---|---|---|---|
post | How to customize theming in Syncfusion controls | Learn here about how to switch between light and dark themes in Syncfusion Xamarin controls and more details. | xamarin | General | ug |
Switching between light theme and dark theme
To switch to light theme from dark theme, use the following code snippet.
{% highlight C# %}
void UpdateTheme(object sender, System.EventArgs e)
{
ICollection mergedDictionaries = Application.Current.Resources.MergedDictionaries;
var darkTheme = mergedDictionaries.OfType().FirstOrDefault();
if (darkTheme != null)
{
mergedDictionaries.Remove(darkTheme);
}
mergedDictionaries.Add(new LightTheme());
}
{% endhighlight %}
Similarly, to switch to dark theme from light theme, remove the light theme resource, and add the dark theme resource dictionary.
The complete Theme switch sample is available in this link.