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.
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));
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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.