In my WPF app, as I select channels from a listbox I create a y-axis, x-axis, add them to the xamdatachart, create a series and link the axes to the series and then add the series to the chart. When I deselect the channel from the listbox I use XamDataChart.Remove[axis/series] to remove the 2 axes and the series. If there is no data in the collections the series ans axes are bound to then they remove without issue. However, as soon as the collections contain any data and I try to remove the x-axis I get a NullReferenceException. I have narrowed down the issue to when I create the x-axis I bind the MinimumValueProperty and MaximumValueProperty to the Min and Max value properties of the viewmodel. This value gets updated each time any of the collections gets updated so that I can maintain a specific window size. To work around the issue I simply use BindingOperations.ClearAllBindings(xaxis) just before I remove the axis. Am I doing something wrong here? Should I not bind those two properties? Is there a more appropriate way to create a static size window with N StepLine series bound to data coming in a all different intervals?
HI Mike,
You could also set the bindings up using a Converter and in the converter check for nullvalues and return zero in that case.
Another possible option would be to simply hide the series and the axis, by setting thier visiblity property to collapsed.
Sincerely, Matt Developer Support Engineer
Matt,
If I just hide the series with it still update the chart as points are added to the colloection? There will be many graphs being drawn so if a user deselects one I want it to not use any resources trying to draw it.
Mike
Clearing all the bindings is working for me. I'll stick with that approach.
Thanks.
HI,
Please let me know if you need further assistance regarding this issue.
Sincerely,
Matt Developer Support Engineer
I guess it would still process the data. If ClearAllBindings is not working for you, I will just use a converter and make sure zero is passed when the values are null.