Reputation: 15474
I want to add LineSeries
without points just lines. I want to do this dynamically from code not xaml.
I tried to do this with following code:
Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.VisibilityProperty,Visibility.Hidden));
var series = new LineSeries()
{
Title = name,
DependentValuePath = "Y",
IndependentValuePath = "X",
ItemsSource = new ObservableCollection<FloatingPoint>(),
DataPointStyle = style,
};
chart.Series.Add(series);
However it doesn't work; I still see the points.
Upvotes: 1
Views: 8084
Reputation: 11
In order to hide the data points set width and height to 0 of the same.
style.Setters.Add(new Setter(LineDataPoint.WidthProperty, 0.0));
style.Setters.Add(new Setter(LineDataPoint.HeightProperty, 0.0));
Upvotes: 1
Reputation: 14037
I have answered a similar question here.
Briefly: the Visibility
property won't work, you should set the Template
property to null.
Corrected lines:
Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, null));
Upvotes: 3