Claus Jørgensen
Claus Jørgensen

Reputation: 26347

UIElement position relative to Window

In WPF, I want to get the corner location of a TabControl in my code, so I can set a ToolWindow's location accordingly when shown.

How do I get the location of a given UIElement?

buildingInfoWindow = new BuildingInfoWindow(); // BuildingWindow : System.Windows.Window
buildingInfoWindow.Owner = this;

//buildingInfoWindow.Left = ?; // relative X coordinate of my TabControl
//buildingInfoWindow.Top = ?; // relative Y coordinate of my TabControl

Upvotes: 3

Views: 3439

Answers (1)

Jobi Joy
Jobi Joy

Reputation: 50038

Point pt = tabControl.TranslatePoint(new Point(0, 0), windowInstance);

Upvotes: 7

Related Questions