10-14-2024 09:42 AM
Hello,
I've a WPF Cursor in a WPF Graph.
I would like to set the cursor X position at a value but it requests both X, Y value.
Is there a way to set the cursor with only the X position ?
Thanks
ps : is possible, I would like not to have to compute the Y position. 🙂
10-14-2024 05:32 PM
If you are only interested in controlling the X value, you might consider switching to MultiPlotCursor
: it will use the host graph's horizontal axis by, allowing you to set the AxisValue
property directly to your target X value, and the Values
property will report all intersecting plot data values. To limit this to a single plot like Cursor
, you can configure the AllowablePlots
property accordingly. If you are trying to traverse plot values in sequence, the multi-plot cursor also has MoveNext
/MovePrevious
methods, without needing to calculate the "next X" value yourself.
If Cursor
is a better fit for your scenario, you can use the SetDataPosition
method and specify it to search only in the horizontal direction when finding the closest plot value:
var x = ...; // your target X value
var y = this.cursor.Value[1]; // existing Y value
this.cursor.SetDataPosition(new[] { x, y }, SearchDimensions.Horizontal);