无边界窗口应用程序比我的屏幕分辨率占用更多的空间 [英] Borderless window application takes up more space than my screen resolution

查看:92
本文介绍了无边界窗口应用程序比我的屏幕分辨率占用更多的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在WPF中创建了一个无边界的应用程序,并且效果很好.但是,当我将WindowState设置为全屏时,该应用程序比我的屏幕分辨率占用更多的空间,因此在屏幕的各个方向上都有一些像素! (看起来好像添加了一些硬编码负边距以隐藏默认边框)

I have created a borderless application in WPF, and it works pretty good. However, when I set the WindowState to full screen, the application takes up more space than my screen resolution, so there are some pixels outside the screen in all directions! (looks like some hard coded negative margins are added to hide the default border)

任何想法如何防止这种情况发生?

Any Ideas how to prevent this from happening?

我的xaml:

<Window x:Class="MyApp.Shell"
    WindowStyle="None"
    BorderThickness="0"
    AllowsTransparency="True"
    Background="Transparent"
    ResizeMode="CanResizeWithGrip"
    WindowState="{Binding MainApplicationWindowState}"
    ...

另外,我看到的另一个问题是Windows工具栏/任务栏以全尺寸状态覆盖,因此看起来是使用实际"屏幕高度而不是可用"屏幕高度,这意味着屏幕高度减去Windows工具栏/任务栏!

Also, another problem I have seen is that the Windows toolbar / taskbar is covered in the fullsize state, so it looks like the "actual" screen height is used and not the "available" screen height, meaning screen height minus the windows toolbar / taskbar!

有人找到了解决这些问题的方法吗?

Anyone found a solution to these issues?

谢谢

推荐答案

我通过以下方式解决了这个问题:

I solved the problem this way:

XAML:

WindowStyle="None"
Left="0"
Top="0"
Width="{Binding WPFSettings.Width}"
Height="{Binding WPFSettings.Height}">

Visual Basic:

Public Class WPFSettings
   Public ReadOnly Property Width() As Double
      Get
         Return System.Windows.SystemParameters.PrimaryScreenWidth
      End Get
   End Property

   Public ReadOnly Property Height() As Double
      Get
         Return System.Windows.SystemParameters.PrimaryScreenHeight
      End Get
   End Property
End Class

效果很好.

这篇关于无边界窗口应用程序比我的屏幕分辨率占用更多的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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