Search code examples
wpfwpf-controls

How to set the location of a WPF window?


I have a ListView in which I have defined a custom cell as a UserControl.

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

I want the 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.


Solution

  • Window.Left and Window.Top

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