We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change SfChart background when calling the Save method

Thread ID:





132390 Aug 30,2017 07:10 AM UTC Sep 1,2017 04:47 AM UTC WPF 3
Tags: SfChart
Asked On August 30, 2017 07:10 AM UTC


is it possible to change the background color it is used to cretate the image file when the SfChart.Save method is called?
I have, in fact, situations where the users changes the background color of the App using SfSkinManager and it seems to me that the Save method always uses the current GUI background color to produce the image file.
But in this case, it should be better for me to force a fixed background color (say Transparent or White), when saving instead of using the current background GUI color set by the user.
Is it possible to do this ?

Silvio Scattaglia

Durgadevi Selvaraj [Syncfusion]
Replied On August 31, 2017 12:37 PM UTC

Hi Silvio, 
Thanks for contacting Syncfusion Support. 
We have analyzed your requirement and can be achieved by applying visual styles as Office2016White before save the chart and then we can set existing Visual Style to the chart as like in the below code, 
<Button Content="Save" Width="100" Height="50" Click="Button_Click"/> 
  private async void Button_Click(object sender, RoutedEventArgs e) 
            Syncfusion.SfSkinManager.SfSkinManager.SetVisualStyle(chart, Syncfusion.SfSkinManager.VisualStyles.Office2016White); 
            await Task.Delay(50); 
            Syncfusion.SfSkinManager.SfSkinManager.SetVisualStyle(chart, Syncfusion.SfSkinManager.VisualStyles.Blend); 
Please find the output screenshots, 
1.Before saving the  chart. 
2.Saved image of the chart. 
Also, we can achieve your requirement (saving chart with white background) by changing the chart Background and AreaBackground as white before save the chart and then we can set chart Background and AreaBackground as existing color as shown in the below code, 
     Brush background; 
        Brush areabackground; 
        private async void Button_Click(object sender, RoutedEventArgs e) 
            background = chart.Background; 
            areabackground = chart.AreaBackground; 
            chart.Background = new SolidColorBrush(Colors.White); 
            chart.AreaBackground = new SolidColorBrush(Colors.White); 
            await Task.Delay(50); 
            chart.Background = background; 
            chart.AreaBackground = areabackground; 
We have prepared a demo sample for your reference and please find it from below link, 
Please let us know if you have any concerns. 
Durgadevi S 

Replied On August 31, 2017 02:07 PM UTC

Thank you for your help.

I tried the same your method but without using the trick of recalling the Task.Delay and it didn't work.

Recalling this method in an asyncronous way now it works!

Thank you.

Silvio Scattaglia

Durgadevi Selvaraj [Syncfusion]
Replied On September 1, 2017 04:47 AM UTC

Hi Silvio, 
We glad to know that your problem has been resolved. 
Please let us know if you required any further assistance on this. 
Durgadevi S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon