Search code examples
c#visual-studiovisual-studio-extensionsvisual-studio-sdk

How to get the screen position of Visual Studio UI Elements?


I am developing a Visual Studio Extension.

Is there any way to get the position of the IDE's UI Elements?

So for example I would need the screen coordinates of a toolbar item like the Run Application - Button.

As far as I see the corresponding UI Element Classes of the Visual Studio SDK do not provide any position properties...


Solution

  • Visual Studio UI is WPF, so you can use System.Windows.Media.VisualTreeHelper to enumerate and locate UI elements.