Articles in this section
Category / Section

How to Configure and Customize Theme in .NET MAUI Sunburst Chart?

3 mins read

In this article, we will learn how to configure and customize the .NET MAUI Syncfusion theme for the SfSunburstChart. Syncfusion themes enable you to apply colors uniformly to .NET MAUI Sunburst Charts, providing a consistent look and feel for your applications.

Let’s take a look at the following sections:

  1. How to Set the Theme for the Application
  2. Dynamically Changing Themes
  3. Overriding the Default Theme
How to Set the Theme for the Application

By default, Syncfusion provides support for both light and dark themes through the inclusion of a SyncfusionThemeResourceDictionary.

Initialize and assign the desired theme in your application, modify the App.xaml file as follows:

<Application xmlns:syncTheme="clr-namespace:Syncfusion.Maui.Themes;assembly=Syncfusion.Maui.Core">
   
   <Application.Resources>
       <ResourceDictionary>
           <ResourceDictionary.MergedDictionaries>
               <syncTheme:SyncfusionThemeResourceDictionary VisualTheme="MaterialLight"/>
           </ResourceDictionary.MergedDictionaries>
       </ResourceDictionary>
   </Application.Resources>

</Application> 

Light Theme

Demo for Sunburst Chart Light Theme

Dark Theme

Demo for Sunburst Chart Dark Theme

Dynamically Changing Themes

Syncfusion allows for dynamic theme switching within your application. This can be achieved by updating the VisualTheme property at runtime. Here is an example in C#:

ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
if (mergedDictionaries != null)
{
    var theme = mergedDictionaries.OfType<SyncfusionThemeResourceDictionary>().FirstOrDefault();
    if (theme != null)
    {
        if (state == false)
        {
            theme.VisualTheme = SfVisuals.MaterialLight;
        }
        else
        {
            theme.VisualTheme = SfVisuals.MaterialDark
        }
    }
} 

ThemeDemo

Overriding the Default Theme

The theme resource dictionary contains a set of keys that are mapped to styles in control style dictionaries. The default appearance of themes can be customized by overriding these key values. You can find the keys for the Sunburst Chart here: Sunburst Chart Theme Keys.

For example, here the tooltip background and text color values are customized by overriding theme keys.

<Application xmlns:syncTheme="clr-namespace:Syncfusion.Maui.Themes;assembly=Syncfusion.Maui.Core">
   
   <Application.Resources>
       <ResourceDictionary>
           <ResourceDictionary.MergedDictionaries>
               <syncTheme:SyncfusionThemeResourceDictionary VisualTheme="MaterialLight"/>

               <ResourceDictionary>
                  <Color x:Key="SfSunburstChartTooltipBackground">Purple</Color>
                  <Color x:Key="SfSunburstChartTooltipTextColor">Orange</Color>
               </ResourceDictionary>

           </ResourceDictionary.MergedDictionaries>
       </ResourceDictionary>
   </Application.Resources>
</Application> 

Demo for Theme Key Customization

For more information, please refer to the Syncfusion .NET MAUI Sunburst Chart Theme Demo

Conclusion

I hope you enjoyed learning how to configure and customize themes in .NET MAUI Sunburst Chart
You can refer to our .NET MAUI Sunburst Chart feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to present and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trail to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied