SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


I’ve been beating my head over this for a while and I’m wondering if there’s something wrong with my implementation or whether there’s a bug in the annotationlabel.

I am running into a nullreferenceexception when I begin drag on an Axis AnnotationLabel attached to a VerticalLineAnnotation. An example code is below. This doesn’t seem to be an issue for non-axis labels.

I am able to drag once. When I begin my second drag on the label the crash occurs. This crash does not occur when the annotation line itself is dragged. The crash occurs when you click on the annotation label (at the axis) and drag it twice in succession.

Note — this issue doesn’t crop up when the annotation and label are declared in xaml. For my purposes however, I have been trying to create them programmatically. My actual code is a bit different, I add the label in the codebehind as opposed to the viewmodel, but this below gives the same outcome.

Edit: on further investigation, this seems to occur with annotationviewmodels specifically. Creating the annotation through the codebehind works fine. But creating it via an AnnotationsBinding and annotationviewmodel does not. I found the issue occurs when I set “ShowLabel” on the annotationviewmodel as well as when I add to the label collection.

var a = new VerticalLineAnnotationViewModel()
                    X1 = someInitialVal,
                    XAxisId = "DateTimeXAxis",
                    YAxisId = "PressureYAxis",
                    DragDirections = SciChart.Charting.XyDirection.XDirection,
                    IsEditable = true,

                a.AnnotationLabels.Add( new SciChart.Charting.Visuals.Annotations.AnnotationLabel() );
                Annotations.Add( a);
                RaisePropertyChanged( nameof( Annotations ) );
  • You must to post comments

If anyone else is running into the same issue, the workaround I found is overriding OnAnnotationMouseMove in the Annotation and returning without calling base if the sender is not the annotation (i.e. is the label or one of the elements in the label).

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.