简体   繁体   English

为什么我的应用程序窗口会关闭屏幕?

[英]Why is my application window going off screen?

I have a C# WPF application I am building. 我正在构建一个C#WPF应用程序。 Currently when I run it on my machine in a 1024 x 768 screen resolution environment it all fits. 目前,当我在1024 x 768屏幕分辨率环境下在我的机器上运行时,它都适合。 However when I send it to a co-worker he has a 1280 x 800 resolution and the application window runs off the bottom edge of his screen so he cant re-size it or see all of the content in the window. 然而,当我将它发送给同事时,他的分辨率为1280 x 800,应用程序窗口从屏幕的底部边缘运行,因此他无法重新调整大小或查看窗口中的所有内容。 I am running Windows 7 and he is running Windows XP if that makes any difference. 我正在运行Windows 7,如果这有任何不同,他正在运行Windows XP。 In addition in my XAML code I have the 'Height' and 'MinHeight' attributes both set to 700, so I would think it shouldn't start out taller than 700. 另外在我的XAML代码中,我将'Height'和'MinHeight'属性设置为700,所以我认为它不应该高于700。

Any ideas are appreciated, thanks in advance. 感谢任何想法,提前感谢。

WPF specifies sizes and locations in inches , not in pixels. WPF以英寸为单位指定尺寸和位置,而不是像素。 The unit is 1/96 inch. 单位是1/96英寸。 So your Height setting of 700 specifies a window that's 700 / 96 = 7.292 inch high. 因此,您的高度设置为700指定一个700/96 = 7.292英寸高的窗口。

In all likelihood, your co-worker might be wearing glasses and has increased the dots-per-inch setting of his video adapter from 96 to 120 dpi (125% on the ruler) to make it easier to read text. 很可能,您的同事可能戴着眼镜,并将其视频适配器的每英寸点数设置从96 dpi增加到120 dpi(标尺上为125%),以便于阅读文本。 Which makes your window 7.292 * 120 = 875 pixels high. 这使得你的窗口7.292 * 120 = 875像素高。 That doesn't fit the 800 pixels that the monitor can display. 这不适合显示器可以显示的800像素。

You'll need to make your window smaller. 你需要让你的窗户更小。 No more than 800 / 120 * 96 = 640. Less to allow room for the task bar if it is on the bottom. 不超过800/120 * 96 = 640.如果任务栏位于底部,则允许空间。 Or preferably support resizable window layouts. 或者最好支持可调整大小的窗口布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM