Pre loader

Y Axis Drag Listener

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

Answered
0
0

I’m wondering how to add a DragListener to the YAxis in WPF so that I can tell when my YAxisDragModifier has been invoked. I tried adding a custom EventHandler to the SciChartSurface.YAxis like so: DragEnter=”YAxisDragModifier_DragEnter” but the method wasn’t forwarded any events. I also set ReceiveHandledEvents=”True” in my YAxisDragModifier, but that didn’t seem to help.

Version
v5
  • You must to post comments
Best Answer
1
0

Hi Jacob

If you want to be notified when a YAxisDragModifier is used, please try something like this code:

public class YAxisDragModifierEx : YAxisDragModifier
{
    public event EventHandler<EventArgs> Dragged;

    protected override void PerformPan(Point currentPoint, Point lastPoint)
    {
        base.PerformPan(currentPoint, lastPoint);
        Dragged?.Invoke(this, EventArgs.Empty);
    }

    protected override void PerformScale(Point currentPoint, Point lastPoint, bool isSecondHalf)
    {
        base.PerformScale(currentPoint, lastPoint, isSecondHalf);
        Dragged?.Invoke(this, EventArgs.Empty);
    }
}

Note that this will fire events continuously as the YAxisDragModifier is dragged or panned.

If you want a single event at the end of an operation, try this instead.

public class YAxisDragModifierEx : YAxisDragModifier
{
    private bool wasDragged;
    public event EventHandler<EventArgs> DragEnd;

    protected override void PerformPan(Point currentPoint, Point lastPoint)
    {
        base.PerformPan(currentPoint, lastPoint);
        this.wasDragged = true;
    }

    protected override void PerformScale(Point currentPoint, Point lastPoint, bool isSecondHalf)
    {
        base.PerformScale(currentPoint, lastPoint, isSecondHalf);
        this.wasDragged = true;
    }

    public override void OnModifierMouseUp(ModifierMouseArgs e)
    {
        base.OnModifierMouseUp(e);
        if (this.wasDragged)
        {
            DragEnd?.Invoke(this, EventArgs.Empty);
            this.wasDragged = false;
        }
    }
}

Let me know if that helps! For more info about our powerful chartmodifier API take a look at the ChartModifier Sandbox project on github

Best regards,
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