Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3590
NullReferenceException when removing xaxis
posted

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? 

Parents
  • 28407
    posted

    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

Reply Children