Hi, I recently upgraded from 2009.1 to 2009.2 of the Silverlight Data Visualization package.
Code which used to work when modifying axis properties of a xamchart now results in a null reference exception.
eg
slChart.Axes[0].AutoRange = false;
slChart.Axes[0].Maximum = 100;
slChart.Axes[0].Minimum = data.Ymin;
slChart.Axes[0].Unit = 10;
the exception occurs on the first set.
The axis object definitely exists and the properties even have values.
In the sample project attached above, the yAxis is not created, it is erroneously assumed to already be in the Axes collection. This is why the NullReferenceException is occuring.
If you run this line:
Axis yAxis = xamWebChart.Axes.FirstOrDefault(a => a.AxisType== AxisType.PrimaryY);
On an empty collection then it will follow that this line raises an exception:
yAxis.AutoRange = false;
If I've misunderstood the situation then please let me know so we can resolve whichever issue you may be having.
-Graham
But what if you're creating charts dynamically (on the fly, without xaml, etc)?
It seems to me that if you create an object, and then tyry to change a public property on said object, and it pukes up a NullReferenceException, if it's not a bug, then it qualifies as piss-poor design.
Kris,
Turns out this isn't a bug and can be easily resolved by creating a PrimaryY axis in XAML. I've re-attached your application with this, and you'll see the null reference exception no longer occurs.
-Marisa
Thanks for your sample application. I was able to reproduce the behavior and have submitted a bug on this, #25754. You can refer to our Developer Support with this bug number for any further information on it.
Thanks,Marisa
I have attached a sample project that illustrates the NullReferenceException that I am encountering. Just open up the solution and hit F5.
-Kris