C# 调整窗口大小(在中央屏幕中)wpf
我需要在所有的工作区域开放C# 调整窗口大小(在中央屏幕中)wpf,c#,wpf,C#,Wpf,我需要在所有的工作区域开放 this.Width = SystemParameters.WorkArea.Width; this.Height = SystemParameters.WorkArea.Height; 但是,窗口在屏幕中的位置不是中心位置,如何在中心屏幕中定位窗口?试试这个 已更新 如果我使用 public MainWindow() { InitializeComponent(); this.Width = SystemParameters.WorkArea.Wi
this.Width = SystemParameters.WorkArea.Width;
this.Height = SystemParameters.WorkArea.Height;
但是,窗口在屏幕中的位置不是中心位置,如何在中心屏幕中定位窗口?试试这个
已更新
如果我使用
public MainWindow() {
InitializeComponent();
this.Width = SystemParameters.WorkArea.Width;
this.Height = SystemParameters.WorkArea.Height;
this.Top = 0;
this.Left = 0;
}
如果没有WindowsStartUpLocation,窗口将居中并填充屏幕使用
在XAML中
<Window WindowState="Maximised">
// ...
</Window>
像这样写。
WindowStartupLocation=“CenterScreen”>也许您应该使用它。Top=0;左=0;但窗口不是位置世界区域,他是全屏幕,你们需要完善你们的问题。从模糊的答案可以看出,您的问题没有充分描述您的问题。请更全面地解释您的答案,它们将对OP和其他人更有用。
MyWindow mw = new MyWindow();
mw.WindowState = WindowState.Maximised;