I am new to Silverlight and am currently entering Charting territory. I follow a few tutorials that show how easy it is to bind ColumnSeries to a data source using ItemsSource ( http://silverlight.net/forums/t/44166.aspx ).
I programmatically add a chart to the canvas.
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;
cs.IndependentValueBinding = new System.Windows.Data.Binding("Budget");
cs.DependentValueBinding = new System.Windows.Data.Binding("Year");
This code compiles fine. However, when I debug it, this error is thrown. Nevertheless, I have great difficulty with the ItemsSource. Each time I assign an ItemSource, I get a Sys.InvalidOperationException: ManagedRuntimeError error # 4004 error in the "Xaml1" control: System.NullReferenceException System.NullReferenceException: the object is not set to an object instance. in System.Windows.Control.DataVisualization.Charting.ColumnSeries. <> c__DisplayClass8.b__4 ()
Please help, this mistake is driving me crazy !!!
source
share