【发布时间】:2010-10-13 16:51:47
【问题描述】:
我正在尝试以编程方式将列系列添加到 wpf 工具包图表。我的 xaml 是一个空图表。该代码导致未处理的异常,对象引用未设置为对象的实例。为什么这不起作用的任何线索?
<charting:Chart Name="MyChart">
我的代码是
List<KeyValuePair<int,int>> testList = new List<KeyValuePair<int,int>>();
testList.Add(new KeyValuePair<int,int> (1,2));
testList.Add(new KeyValuePair<int,int> (2,3));
ColumnSeries mySeries = new ColumnSeries();
mySeries.Title = "TEST";
mySeries.IndependentValueBinding = new Binding("key");
mySeries.DependentValueBinding = new Binding("value");
mySeries.ItemsSource = testList;
MyChart.Series.Add(mySeries);
【问题讨论】:
标签: c# wpf wpftoolkit