Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using the WPFToolkit to create a line chart with multiple LineSeries(multiple colors)
I want to change the line color dynamically,
please can anyone help me plzz..

i tried bt it is not working
thnax.

What I have tried:

C#
Style style = new Style(typeof(LineSeries));
            var color = (Color)ColorConverter.ConvertFromString(linecontrolWindow.BatchTimeLine);
            style.Setters.Add(new Setter(LineSeries.DataPointStyleProperty, color));
            Series1.Style = style;


showing error:

'#FF800000' is not a valid value for the 'System.Windows.Controls.DataVisualization.Charting.DataPointSingleSeriesWithAxes.DataPointStyle' property on a Setter.
Posted
Updated 3-May-16 21:13pm
v3

1 solution

It looks like the type of the DataPointStyle property is Style and, you try to set to it a value of type Color...

 
Share this answer
 
Comments
Member 11859517 4-May-16 3:23am    
i tried type of datapoint that aloso not working

Style style = new Style(typeof(DataPoint));
var color = (Color)ColorConverter.ConvertFromString(linecontrolWindow.BatchTimeLine);
style.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(color)));
this.Series1.DataPointStyle = style;

here no error showing, bt output not change.
Shmuel Zang 4-May-16 3:35am    
Maybe you set the Background property in the element's XAML. If so, it overrides the style's value.
Member 11859517 4-May-16 4:27am    
thanx shmuel,
yes, i am setting in background xaml, bt again i want to change from code? is it possible?
Shmuel Zang 4-May-16 5:55am    
Why changing it from the code? It isn't the best practice. Maybe you want to use binding?
Member 11859517 4-May-16 6:09am    
actualy, i am giving option to user to change it,,,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900