如何在应用程序启动时最大化 WPF 页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26425485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 12:37:13  来源:igfitidea点击:

How can I maximize a WPF page when the application starts?

c#wpfxaml

提问by MarianoDiego

I have a simple WPF application with two xaml Pages. I'd like the app opening with the maximum size of the screen. I've found only answers about WPF Windows, but for Pages there is not a "WindowState" property.

我有一个带有两个 xaml 页面的简单 WPF 应用程序。我希望应用程序以最大屏幕尺寸打开。我只找到了有关 WPF Windows 的答案,但对于 Pages 没有“WindowState”属性。

Thanks a lot!

非常感谢!

回答by Hardgraf

In your Xaml window definition simply define:

在您的 Xaml 窗口定义中,只需定义:

WindowStartupLocation="CenterScreen" WindowState="Maximized"

回答by coder0815

You could set the Widthand Heightproperty manually according to your current Screen Resolution from here

您可以从此处根据您当前的屏幕分辨率手动设置WidthHeight属性

System.Windows.SystemParameters.PrimaryScreenWidth;
System.Windows.SystemParameters.PrimaryScreenHeight;