Articles in this section
Category / Section

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

3 mins read

This article guides you through configuring and customizing the .NET MAUI Syncfusion® theme for the SfCircularChart. Syncfusion® themes enable you to apply colors uniformly to .NET MAUI Circular Charts, ensuring 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® supports light and dark themes through the inclusion of a SyncfusionThemeResourceDictionary.

Initialize and assign the desired theme in your application by modifying 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 Circular Chart Light Theme

Dark Theme

Demo for Circular 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 Circular Chart here: Circular Chart Theme Keys.

For example, 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="SfCircularChartTooltipBackground">Violet</Color>
                   <Color x:Key="SfCircularChartTooltipTextColor">Brown </Color>
               </ResourceDictionary>

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

Demo for Theme Key Customization

Download the complete sample from GitHub.

Conclusion
I hope you enjoyed learning how to configure and customize the theme in .NET MAUI Circular Chart.
You can refer to our .NET MAUI Circular Chart feature tour page to learn about its other groundbreaking feature representations. 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®, try our 30-day free trial to check out our other controls. Please let us know in the comments section if you have any queries or require clarification. 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