---
title: "How to get XY coordinates of a control in WPF?"  
description: "How to get XY coordinates of a control in WPF?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1499/how-to-get-xy-coordinates-of-a-control-in-wpf  
category: "wpf"  
tags: ["wpf", "mindstick", "WPF control", "get XY coordinates", "get XY coordinates of a control in WPF"]  
reading_time: 1 minute  

---

# How to get XY coordinates of a control in WPF?

Point relativePoint = myVisual.TransformToAncestor(rootVisual)

.Transform(new Point(0, 0));

this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) [block](https://www.mindstick.com/forum/157599/explain-the-process-control-block-pcb-in-the-operating-system) is very [useful](https://www.mindstick.com/articles/12694/how-dolomite-mineral-is-useful-in-human-life) but, I use [MVVM](https://www.mindstick.com/forum/12742/how-to-use-this-code-in-wpf-application-with-mvvm) therefore the code block is useless for me ?

I wanna to get X &[amp](https://www.mindstick.com/forum/156207/what-is-amp); Y without using rootVisual.

Thanks & Best Regards.

## Replies

### Reply by Pravesh Singh

Hi Ben,You can try this :\

var parent = VisualTreeHelper.GetParent(myVisual) as UIElement;

Point relativePoint = myVisual.TransformToAncestor(parent)

.Transform(new Point(0, 0));


---

Original Source: https://www.mindstick.com/forum/1499/how-to-get-xy-coordinates-of-a-control-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
