如何设置 WPF 窗口的位置? [英] How to set the location of a WPF window?

查看:93
本文介绍了如何设置 WPF 窗口的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,我在其中定义了一个自定义单元格作为用户控件.

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

在我为用户提供超链接的自定义单元格中,当用户单击超链接时,我会显示一个 WPF 对话框.

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

我希望 WPF 对话框位于超链接上方..

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.

推荐答案

Window.LeftWindow.Top

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

这篇关于如何设置 WPF 窗口的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆