You can use the MouseMove events of both the RadDiagram and RadDiagramRuler like so:
privatevoidRadDiagram_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
var viewport = this.diagram.Viewport;
var pos = e.GetPosition(this.diagram);
this.X.Text = ((pos.X / diagram.Zoom) + viewport.Location.X).ToString();
this.Y.Text = ((pos.Y / diagram.Zoom) + viewport.Location.Y).ToString();
}
privatevoidRadDiagramRuler_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
var viewport = this.diagram.Viewport;
var pos = e.GetPosition(this.diagramRuler);
this.X.Text = ((pos.X / diagram.Zoom) + viewport.Location.X).ToString();
this.Y.Text = viewport.Location.Y.ToString(); // if you're using a vertical ruler, you can set the X value instead
}
You can notice that I use the Zoom and Viewport properties to calculate the offset when zooming is applied. As specified in the comment, you need to set the X and Y values accordingly when using a vertical ruler instead.
Please have a look at the sample project I've prepared and let me know if a similar approach would work at your end.
Regards,
Dilyan Traykov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.