我正在尝试以编程方式在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);
答案 0 :(得分:0)
Bar1.DependentValuePath =&#34; Value&#34 ;; 代替: Bar1.IndependentValuePath =&#34; Value&#34 ;;