WPF最大化窗口大于屏幕 [英] WPF Maximized Window bigger than screen

查看:675
本文介绍了WPF最大化窗口大于屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 AllowsTransparency = True WindowStyle = None 创建WPF窗口并通过 this.WindowState = WindowState.Maximized最大化时; 窗口大于我的屏幕。

When creating a WPF window with AllowsTransparency="True" WindowStyle="None" and maximizing it via this.WindowState = WindowState.Maximized; the Window gets bigger than my screen.

设置 AllowTransparency = False 我的窗口周围有边框,但是窗口不会比屏幕大。

就我而言,我有1920x1080的屏幕,窗口变成了1934x1094。

在我的1280x1024屏幕上,该窗口将变为1294x1038。

不管是否启用AllowTransparency,该窗口仍将与之一样大。

When setting AllowTransparency="False" i have a border around my Window, but the window won't get bigger than my screen.
In my Case I have a 1920x1080 screen and the window becomes 1934x1094.
On my 1280x1024 screen the window will become 1294x1038.
The Window will become still as big as this, whether or not AllowTransparency is enabled or not, yet with it disabled it works properly.

在最大化之前设置AllowTransparency无效,并引发InvalidOperationException。

Setting AllowTransparency before maximizing doesen't work and throws an InvalidOperationException.

如何获取没有Windows样式边框的WPF窗口,但尚未正确最大化?

How to get a WPF window without a Windows-style border, but yet to maximize properly?

推荐答案

这似乎是一个非常普遍的问题。看来您必须按照此StackOverflow文章中所述将高度和宽度绑定到屏幕的实际高度/宽度:

It seems a pretty common issue. It appears you'll have to bind your height and width to the actual height/width of the screen as stated in this StackOverflow post:

无边框窗口应用程序比我的屏幕分辨率占用更多的空间

我希望能解决您面临的问题。

I hope that solves the issue you're facing.

这篇关于WPF最大化窗口大于屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆