8
我有一些图表,我想动态添加LineSeries没有数据点,只是线条有一些自定义颜色。我发现隐藏的数据点的唯一方法是:wpf工具包线条图没有点和不同的线条颜色
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;
+1太棒了!非常感谢! – Legend
这应该是被接受的答案。 +1帮助我解决问题。这也适用于XAML。 –