OxyPlot get clicked point

徘徊边缘 提交于 2019-12-04 09:01:44
kennyzx

PlotView has defined Mouse events, from which you can get the mouse coordinates. And InverseTransform is used to translate mouse coordinates to plot coordinates.

Example:

var model = new PlotModel { Title = "Test Mouse Events" };

var s1 = new LineSeries();
model.Series.Add(s1);

double x;

s1.MouseDown += (s, e) =>
    {
        x = (s as LineSeries).InverseTransform(e.Position).X;
    };

I couldn't get the accepted answer to work. The MouseDown handler wouldn't receive events when the plot was left-clicked. It would, however, receive events for right-clicks and double-clicks.

My workaround is to listen for PreviewMouseDown on the PlotView.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!