wpf不同颜色的面积图?

我是一个沉思MS工具包图表,无法弄清楚如何改变区域的颜色。 我需要动态填充图表,这意味着我不知道区域图表将包含多少部分。

这是我的代码。

var a = new AreaSeries { Title = "a", IndependentValuePath = "Key", DependentValuePath = "Value", Background = Brushes.Plum }; 

我试图改变前景和背景,没有骰子。

 mcChart.Series.Add(a); a = new AreaSeries { Title = "b", IndependentValuePath = "Key", DependentValuePath = "Value", Background = Brushes.Peru }; mcChart.Series.Add(a); 

填写图表。

 ((AreaSeries)mcChart.Series[0]).ItemsSource = new[] { new KeyValuePair("1", 100), new KeyValuePair("2", 180), new KeyValuePair("3", 110), new KeyValuePair("4", 95), new KeyValuePair("5", 40), new KeyValuePair("6", 95) }; ((AreaSeries)mcChart.Series[1]).ItemsSource = new[] { new KeyValuePair("1", 150), new KeyValuePair("2", 280), new KeyValuePair("3", 310), new KeyValuePair("4", 195), new KeyValuePair("5", 340), new KeyValuePair("6", 195) }; 

我是wpf的新手,我无法弄清楚这有什么问题。

这是XAML

   

如何更改区域a和区域b的颜色。 现在,即使我设置了背景和前景,它们也是默认的颜色。

谢谢。

您可以使用Chart.Palette属性,如下所示:

                 
  • 这是一些更多信息。