0

我正在尝试以编程方式在 WPF 中添加一个图表,然后向其中添加一个条形图,但是我收到一个错误,指出缺少 chart.cs 或 DataPointSeries.cs。我添加了 Toolkit dll。此外,如果我删除 Bar1.Itemsource 代码,图表可以工作,但没有图表但有图例。有任何想法吗?

Chart Ch1 = new Chart();


BarSeries Bar1 = new BarSeries();
List<KeyValuePair<string, int>> valueList = new List<KeyValuePair<string, int>>();
valueList.Add(new KeyValuePair<string, int>("Tom", 2220));
valueList.Add(new KeyValuePair<string, int>("Jim", 23330));

Bar1.ItemsSource = valueList;

Bar1.IndependentValuePath = "Key";
Bar1.IndependentValuePath = "Value";   


Ch1.Name = "BarChart";
Ch1.Series.Add(Bar1);

Grid Backgrid = new Grid();
Backgrid.Children.Add(Ch1);
4

1 回答 1

0

Bar1.DependentValuePath = "值"; 而不是: Bar1.IndependentValuePath = "Value";

于 2015-08-19T09:52:38.080 回答