I am able to create a context menu for an XYChart (there is one XYChart in the WPFChartViewer control). However if there are multiple XYCharts in the WPFChartViewer using a MultiChart, is there a way to identify which XYChart I was hovering over when I right-clicked the mouse to get the context menu?
You can obtain the mouse coordinates relative to the WPFChartViewer, and then iterate the MultiChart to see which XYChart the mouse is hover on. The following is an example on how to iterate the MultiChart:
private int getChartIndexAt(MultiChart m, Point p)
for (int i = 0; (b = m.getChart(i)) != null; ++i)
if ((p.X >= b.getAbsOffsetX()) && (p.X < b.getAbsOffsetX() + b.getWidth()) &&
(p.Y >= b.getAbsOffsetY()) && (p.Y < b.getAbsOffsetY() + b.getHeight()))
For you case, to obtain the chart that the mouse hovers on at the time of the click, you may use the above function in an mouse click event handler.