【发布时间】:2012-10-31 06:02:00
【问题描述】:
我正在尝试以编程方式在 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);
【问题讨论】:
-
您是否还引用了
System.Windows.Controls.DataVisualization.Toolkit.dll?
标签: c# wpf wpftoolkit