I would like to read the start and end coordinates from a OxyPlot PlotView graph. The following is a code snippet from the ViewModel.
plotModel.MouseDown += (s1, e1) =>
{
if (e1.ChangedButton == OxyMouseButton.Middle)
{
plotModel.MouseUp += (s2, e2) =>
{
if (e2.IsControlDown)
{
DateTime xstart = DateTime.FromOADate(xAxis.InverseTransform(e1.Position.X, e1.Position.Y, yAxis).X);
double ystart = yAxis.InverseTransform(e1.Position.X, e1.Position.Y, yAxis).Y;
DateTime xend = DateTime.FromOADate(xAxis.InverseTransform(e2.Position.X, e2.Position.Y, yAxis).X);
double yend = yAxis.InverseTransform(e2.Position.X, e2.Position.Y, yAxis).Y;
}
};
}
};
The problem is that the value I get for xstart
and ystart
is not correct, it seems like the value for y is just a random number, while the x value is somewhat acceptable. xend
and yend
are correct.
Is there something I should change in the code or is there some alternative way to approach this?
I use the middle button since it highlights the selected area, but I couldn´t find a way to simply get the coordinates of the area.