【发布时间】:2009-06-15 11:48:56
【问题描述】:
我是 Silverlight 开发的新手,目前正涉足 Charting 领域。 我一直在关注几个教程,这些教程展示了使用 ItemsSource (http://silverlight.net/forums/t/44166.aspx) 将 ColumnSeries 绑定到数据源是多么容易。
我正在以编程方式将图表添加到画布。
Chart BudgetChart = new Chart { Title = "budget", MaxHeight= 200, MaxWidth=500};
ColumnSeries cs = new ColumnSeries();
BudgetChart.Series.Add(cs);
cs.Title = "blarg";
cs.ItemsSource = o.Budget; //returns List<Budget>
cs.IndependentValueBinding = new System.Windows.Data.Binding("Budget");
cs.DependentValueBinding = new System.Windows.Data.Binding("Year");
这段代码编译得很好。但是,当我调试它时,会抛出此错误 但是,我在使用 ItemsSource 时遇到了很多困难。每次分配 ItemsSource 时,我都会收到一条错误消息,指出它是 Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.NullReferenceException System.NullReferenceException: Object not set to an instance of an object。在 System.Windows.Control.DataVisualization.Charting.ColumnSeries.c__DisplayClass8.b__4()
请帮忙,这个错误快把我逼疯了!!!
【问题讨论】:
标签: silverlight charts