Hi,
Suppose that I have created 3 threshold HorizontalLineAnnotation:
var line1 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 15, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true };
var line2 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 20, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true };
var line3 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 25, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true };
line1.DragEnter += OnAnnotationDrag;
line1.Drop += OnAnnotationDrag;
line1.MouseLeftButtonDown += OnAnnotationCreated;
line1.MouseLeftButtonUp += OnAnnotationCreated;
chart.Annotations.Add(line1);
}
private void OnAnnotationDrag(object sender, DragEventArgs e)
{
//....
}
private void OnAnnotationCreated(object sender, MouseEventArgs e)
{
//....
}
Now I would like that when I move the first line for example from Y 15 to 17 (+2) also the other two lines change their position of +2.
I attach events of DragEnter or Drop to get the coordinates but never is raised. Instead if I attach events to MouseLeftButtonUp/Down the events work properly. Why? Do you suggest me a good solution?
- 10tony89 asked 11 years ago
- You must login to post comments
Hi Tony,
Thanks for your enquiry about SciChart! We’ve not designed the HorizontalLineAnnotation like this, since its not a Drag & Drop operation. There are ways you can get a notification out of user drag however. We present in this example databinding to the X1 or Y1 property of the annotation. The ViewModel will receive notifications on change if the binding is two-way. You could use this to update the other annotations, again via DataBinding.
Alternatively, since X1, Y1 are DependencyProperties, you could use a PropertyChanged notifier to give you a callback when either event changes.
I hope this is helpful,
Best regards,
Andrew
- Andrew Burnett-Thompson answered 11 years ago
-
Sorry, this is the code: [code title=""] var line1 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 15, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true }; var line2 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 20, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true }; var line3 =new HorizontalLineAnnotation() { HorizontalAlignment = HorizontalAlignment.Stretch, Y1 = 25, DragDirections = XyDirection.YDirection, IsEditable = true, LabelPlacement= LabelPlacement.Axis, ShowLabel=true }; line1.DragEnter += OnAnnotationDrag; line1.Drop += OnAnnotationDrag; line1.MouseLeftButtonDown += OnAnnotationCreated; line1.MouseLeftButtonUp += OnAnnotationCreated; chart.Annotations.Add(line1); } private void OnAnnotationDrag(object sender, DragEventArgs e) { //.... } private void OnAnnotationCreated(object sender, MouseEventArgs e) { //.... } [/code]
-
Ok I use the DataBinding method, it works. Thanks so much! :-o
-
Great! I'm glad it helped :) - Andrew
- You must login to post comments
Please login first to submit.