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。 –