Pre loader

HorizontalLineAnnotation Drag and Drop event not raised

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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 Burnett-Thompson
    Great! I'm glad it helped :) - Andrew
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies