New to Telerik UI for WPFStart a free 30-day trial

Get Click Coordinates Relative to the Image of RadImageEditor

Updated on Sep 15, 2025

Environment

Product Version2021.2.511
ProductRadImageEditor for WPF

Description

How to get the image cooridnates of the clicked point in the RadImageEditor control.

Solution

To do this, you can subscribe to the MouseLeftButtonDown event of RadImageEditor and calculate the coordinates based on the mouse position, the image size and the control's size.

C#
	 public MainWindow()
	 {
     		InitializeComponent();
     		this.imageEditor.AddHandler(RadImageEditor.MouseLeftButtonDownEvent, new MouseButtonEventHandler(imageEditor_MouseLeftButtonDown), true);
 	}
  
	private void imageEditor_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
	{
		var image = e.OriginalSource as Image;
		if (image != null)
		{
			Point mousePosition = e.GetPosition(image);
			double relativeWidth = mousePosition.X / image.ActualWidth;
			double relativeHeight = mousePosition.Y / image.ActualHeight;
			
			var originalImageWidth = ((WriteableBitmap)image.Source).PixelWidth;
			var originalImageHeight = ((WriteableBitmap)image.Source).PixelHeight;

			var pixelXPosition = originalImageWidth * relativeWidth;
			var pixelYPosition = originalImageHeight * relativeHeight;
		}
	}
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support