How to set the location of a WPF window?

Ashish Ashu picture Ashish Ashu · Apr 29, 2010 · Viewed 88.1k times · Source

I have a List View in which I have defined a custom cell as a user control.

In the custom cell I given user hyperlink, I am showing a WPF dialog when user clicks on a hyperlink.

I want WPF dialog comes just above the hyperlink..

Please let me know how can I acheive this or how to set the location of the dialog so that it just comes above the hyperlink.

Answer

Josh picture Josh · Apr 29, 2010

Window.Left and Window.Top

var location = myTextBlock.PointToScreen(new Point(0, 0));
window.Left  = location.X;
window.Top   = location.Y - window.Height;