Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF应用程序最大化问题_Wpf_Window - Fatal编程技术网

WPF应用程序最大化问题

WPF应用程序最大化问题,wpf,window,Wpf,Window,如何在Maximize上设置WPF应用程序的高度和宽度? 我面临的问题是因为不同计算机中windows任务栏的高度不同 目前,我正在这样做。请提出更好的方法 if(this.WindowState==WindowState.Maximized) { this.Height=primaryScreenHeight-10-System.Windows.Forms.SystemInformation.SizingBorderWidth; this.Width=primaryScreenWidth+2*

如何在Maximize上设置WPF应用程序的高度和宽度? 我面临的问题是因为不同计算机中windows任务栏的高度不同

目前,我正在这样做。请提出更好的方法

if(this.WindowState==WindowState.Maximized)
{
this.Height=primaryScreenHeight-10-System.Windows.Forms.SystemInformation.SizingBorderWidth;
this.Width=primaryScreenWidth+2*System.Windows.Forms.SystemInformation.FrameBorderSize.Width;

}

您不需要这样做。如果使用栅格作为布局容器,其中的对象将始终展开以使用所有空间。然后可以使用边距排列子面板。使用各种水平对齐值(左、中、右、拉伸)和垂直对齐值(上、中、下、拉伸),您可以制作几乎任何可缩放的布局,而无需检查应用程序是否最大化/最小化等


是否有您想要实现的特定布局,也许我可以发布一个示例?

对不起-您能更好地解释一下您的问题吗-我不明白为什么正常的最大化是不够的?