【发布时间】:2017-10-22 11:41:00
【问题描述】:
我需要有关设置对话框窗口相对于用户控件的位置的帮助。
我想在窗口启动时在中间用户控件中显示我的窗口。
如何找到我的用户控件的 left 和 tom 位置?
我在我的应用程序中使用此代码,但在 WPF 中无法正常工作。
感谢您的帮助。
private void PossitionWindow(object sender, RoutedEventArgs e)
{
Window wind = new Window();
var location = this.PointToScreen(new Point(0, 0));
wind.Left = location.X;
wind.Top = location.Y - wind.Height;
location.X = wind.Top + (wind.Height - this.ActualHeight) / 2;
location.Y = wind.Left + (wind.Width - this.ActualWidth) / 2;
}
【问题讨论】:
-
您想在应用程序主窗口的中心显示对话框吗?
-
不,我想在我的用户控件中心显示对话框窗口。
标签: c# wpf user-controls location