I have a CompositeAnnotation and set CoordinateMode to RelativeX.
How to get absolute X position of the annotation in code behind?
<s:CompositeAnnotation.Annotations>
<s:VerticalLineAnnotation
CoordinateMode="RelativeX"
IsEditable="True"
CanEditText="True"
x:Name="MainAnnotation">
<s:VerticalLineAnnotation.AnnotationLabels>
<s:AnnotationLabel Text="My annotation"
CanEditText="True"
LabelPlacement ="Right"
/>
</s:VerticalLineAnnotation.AnnotationLabels>
</s:VerticalLineAnnotation>
- Alitec Developer asked 9 years ago
- You must login to post comments
I found a simple solution:
protected override void OnAnnotationLoaded(object sender, RoutedEventArgs e)
{
base.OnAnnotationLoaded(sender, e);
MainAnnotation.X1 = this.X1;
}
- Alitec Developer answered 9 years ago
- You must login to post comments
A bit tricky, but it is possible.
Try this code:
double xCoord = Canvas.GetLeft(annotation);
double xDataValue = XAxis.GetDataValue(xCoord);
Best regards,
Andrew
- Andrew Burnett-Thompson answered 9 years ago
- Unfortunately Canvas.GetLeft(annotation) returns NaN value. My sample application: https://1drv.ms/u/s!AhwPkLlDa4zQgfNm7I6o3jc-igIOXA
- You must login to post comments
Please login first to submit.