第一種方法:在xaml中設定
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="測試窗口開啟位置" Height="400" Width="800" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
第二種方法:在Window_Loaded中設定
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Width = 1024.00;
this.Height = 728.00;//this.Left = 600;
this.Top=0;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
}