Change color & style of LineSeries in code behind...

Hi,
I have a chart with 4 LineSeries.

It's getting difficult to work with random color that Framework picks while rendering. 
I want two of the lines with different colors than other two in a set. 
So for example, two related lines will be (Blue & Dashed-blue), while other two could be (Brown & Dashed-brown).

In the xaml it is very easy, at least setting in properties seems to be ok.

            <chart:LineSeries x:Name="SampleLineS" Width="5"
                              Foreground="Beige" StrokeThickness="4" 
                              Interior="#FFCA5D5D"/>



I tried so many ways but could not achieve it in the code behind. I tried to set "Interior" and "Foreground" properties and nothing worked.

            seriesA1.Interior = new Syncfusion.Drawing.BrushInfo(Color.Blue); //new System.Windows.Media.Brush();
            seriesA1.Interior = (System.Drawing.Brush) Brushes.White;
            seriesA1.Foreground = ... more errors of type:

Error CS0029 Cannot implicitly convert type 'System.Drawing.Brush' to 'System.Windows.Media.Brush'


Please help. Also I just want to point out that while searching for this issue, almost every reply seems to be using xaml including the online documentation.

Please provide the same answer in C# and code behind. 

Much appreciated,
Thanks,
-DP








  

3 Replies 1 reply marked as answer

SJ Suyamburaja Jayakumar Syncfusion Team July 27, 2020 09:38 AM UTC

Hi Dhimant Patel, 
 
Greetings from Syncfusion. 
 
We have checked the provided code snippet. We would like to let you know that it will be resolved by setting the Interior property value from System.Windows.Media namespace in C# as per in below 
 
C#: 
series1.Interior = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue); 
series2.Interior = System.Windows.Media.Brushes.Blue; 
series3.Interior = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Brown); 
series4.Interior = System.Windows.Media.Brushes.Brown; 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Suyamburaja J. 


Marked as answer

DP Dhimant Patel July 27, 2020 04:01 PM UTC

Thank you Sir,

It helped.


SJ Suyamburaja Jayakumar Syncfusion Team July 28, 2020 05:10 AM UTC

Hi Dhimant Patel, 
 
We glad to know the given solution works, 
 
Please let us know if you need any further assistance. 
 
Regards, 
Suyamburaja J. 


Loader.
Up arrow icon