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.
- Jacob Stempin asked 2 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 2 years ago
-
Thanks Andrew, Great charting library.
-
Awesome thanks Jacob! have a good day!
- You must login to post comments
Please login first to submit.