2016-01-26 64 views

回答

3

您可以使用WindowStartupLocation属性来设置窗口的显示位置。

在XAML

<Window WindowStartupLocation="CenterParent"> 

或代码

WindowStartupLocation=WindowStartupLocation.CenterOwner 

或者你可以像设置如下

this.Left = mainWindow.Left + (mainWindow.Width - this.ActualWidth)/2; 
this.Top = mainWindow.Top + (mainWindow.Height - this.ActualHeight)/2; 
+0

但是可以根据坐标来做到吗?像我的应用程序的(0,0)中的10 X和10 Y? –

+0

检查编辑答案 – Nantharupan

1

一个简单的方法是使用主窗口的位置。像这样的东西:

OtherWindow other = new OtherWindow(); 
other.Top = mainWindow.Top + 20; 
相关问题