-
I hear ya. Though, I was taking my cue from the “Annotations are Easy” example which uses: …HorizontalLineAnnotation HorizontalAlignment=”Right” FontSize=”12″ FontWeight=”Bold” LabelPlacement=”TopLeft” LabelValue=”Right Aligned, with text on left” ShowLabel=”True” Stroke=”Orange” StrokeThickness=”2″ X1=”5″ Y1=”3.2″… So I assumed the same rules applied for VerticalLineAnnotations. I swore I first tried what you suggested, and set the annotation’s “Content” property to a ‘new AnnotationLabel’, but no text was visible. Thanks.
-
For example, the vertical line appears, but not the text: annotation = new VerticalLineAnnotation { VerticalAlignment = annotation.VerticalAlignment, ShowLabel = false, X1 = time.DateTime, Stroke = Brushes.Orange }; annotation.Content = new AnnotationLabel { LabelPlacement = LabelPlacement.TopLeft, Text = measurement.Annotation };
-
I have actually tried the above in v4.2.x Annotations are Easy example by modifying the VerticalLineAnnotation which already has a child AnnotationLabel. Try it in the example, Maybe the Code behind translation isn’t correct
-
I have to create annotations dynamically – but I’ll see about making it a resource so at least it’s declared in xaml. I find it interesting that the example can set the label to a string. How is that so given the IComparable restriction you mentioned before?
-
Because VerticalLineAnnotation.LabelValue must be numeric, but AnnotationLabel.LabelValue accepts a formatted string. Before you do any big changes — test it out. See if it works.
-
I was referring to line 69 of the “Annotations are Easy” example that sets a HorizontalLineAnnotation LabelValue property to a string value. …HorizontalLineAnnotation HorizontalAlignment=”Right” FontSize=”12″ FontWeight=”Bold” LabelPlacement=”TopLeft” LabelValue=”Right Aligned, with text on left”… By the way, it isn’t the Content property that’s set, but rather the AnnotationLabels property that gets initialized via xaml. I got everything working by simply declaring my annotations using xaml resources.