调整窗口大小(在中央屏幕中)wpf

时间:2012-07-06 07:08:19

标签: c# wpf

我需要在所有工作区域开放

this.Width = SystemParameters.WorkArea.Width;
this.Height = SystemParameters.WorkArea.Height;

但是,窗口不是屏幕中心的位置,我如何在中心屏幕上定位我的窗口?

3 个答案:

答案 0 :(得分:1)

使用WindowState

在XAML中

<Window WindowState="Maximised">
// ...
</Window>

在代码隐藏

MyWindow mw = new MyWindow();
mw.WindowState = WindowState.Maximised;

答案 1 :(得分:1)

这样写。 WindowStartupLocation = “中心屏幕” &GT;

答案 2 :(得分:0)

试试这个WindowStartupLocation

<强>已更新

如果我使用......

public MainWindow() {
    InitializeComponent();
    this.Width = SystemParameters.WorkArea.Width;
    this.Height = SystemParameters.WorkArea.Height;
    this.Top = 0;
    this.Left = 0;
}

没有WindowStartupLocation,窗口居中并填满屏幕

相关问题