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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

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?

  • You must to post comments
0
0

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

  • 10tony89
    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]
  • 10tony89
    Ok I use the DataBinding method, it works. Thanks so much! :-o
  • Andrew
    Great! I'm glad it helped :) - Andrew
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.