【问题标题】:Error while Programmatically adding chart control in WPF在 WPF 中以编程方式添加图表控件时出错
【发布时间】: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


【解决方案1】:

Bar1.DependentValuePath = "值"; 代替: Bar1.IndependentValuePath = "值";

【讨论】:

  • 您好 Khaled,我无法对此进行测试,因为我不再使用 WPF,所以如果您能提供更多详细信息,我可以将此标记为正确答案。
猜你喜欢
  • 2011-02-18
  • 2018-05-26
  • 2014-03-07
  • 1970-01-01
  • 2012-09-10
  • 2011-02-16
  • 1970-01-01
  • 2016-02-12
  • 1970-01-01
相关资源
最近更新 更多