2016-01-26 65 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; 
相關問題