是否有WPF等效于System.Windows.Forms.Screen? [英] Is there a WPF equaivalent to System.Windows.Forms.Screen?

查看:176
本文介绍了是否有WPF等效于System.Windows.Forms.Screen?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个WPF窗口,其中将包含整个桌面工作区域。在WinForms中,我将通过获取 System.Windows.Forms.Screen.AllScreens 中所有界限的并集来实现此目的。

I'm trying to create a WPF window that will encompass the entire Desktop working area. In WinForms I'd do this by getting the Union of all the bounds in System.Windows.Forms.Screen.AllScreens.

是否存在用于在WPF中获取整个桌面范围的等效类型或其他机制,还是需要使用WinForms类型?

Is there an equivalent type or other mechanism to get the bounds of the entire desktop in WPF or do I need to use the WinForms type?

推荐答案

尝试使用SystemParameters.VirtualScreen *(顶部,左侧,高度和宽度)属性。 http:// msdn。 microsoft.com/en-us/library/system.windows.systemparameters.virtualscreenheight(v=VS.100).aspx

Try SystemParameters.VirtualScreen* (Top, Left, Height, and Width) properties. http://msdn.microsoft.com/en-us/library/system.windows.systemparameters.virtualscreenheight(v=VS.100).aspx

不要使用winforms api,因为它没有考虑到WPF的度量单位不是像素这一事实。我刚遇到这个问题是因为我失去了视力,并且将显示器设置为更高的dpi。我正在使用的代码库使用Winforms设置,并且用户界面大于我的屏幕。

Don't use winforms api because it doesn't take into account the fact that WPF's measurement units are not pixels. I came across this issue just recently because I'm losing my vision and have my monitor set to a higher dpi. The codebase I was working on used the Winforms Settings and the UI was larger than my screen.

如果要使用Winforms api。在计算DPI因子

If you're going to use the winforms api. Look at this blog post on calculating the DPI factor.

这篇关于是否有WPF等效于System.Windows.Forms.Screen?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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