我有一些图表,我想动态添加没有数据点的 LineSeries,只是带有一些自定义颜色的线条。我发现隐藏数据点的唯一方法是:
Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, null));
var series = new LineSeries()
{
Title = name,
DependentValuePath = "Y",
IndependentValuePath = "X",
ItemsSource = new ObservableCollection<FloatingPoint>(),
DataPointStyle = style,
};
不幸的是,当我这样做时,所有线条都会变成黄色,并且我无法更改它们的颜色。
我尝试这样做:
Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, null));
SolidColorBrush brush = new SolidColorBrush(Colors.Red);
var series = new LineSeries()
{
Title = name,
DependentValuePath = "Y",
IndependentValuePath = "X",
ItemsSource = new ObservableCollection<FloatingPoint>(),
DataPointStyle = style,
Background = brush,
};
但这没有帮助 - 我无法改变线条颜色......即使我写
series.Background = brush;