获取屏幕分辨率在Win10应用UWP [英] Get Screen Resolution in Win10 UWP App

查看:1672
本文介绍了获取屏幕分辨率在Win10应用UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为UWP应用在普通的桌面系统窗口模式下运行时得到的屏幕分辨率将不再工作的老的方式。

As an UWP App runs in window mode on common desktop systems the "old" way of getting the screen resolution won't work anymore.

旧分辨率, Window.Current.Bounds 像<一个href=\"http://stackoverflow.com/questions/10828179/how-to-get-the-resolution-of-screen-for-a-winrt-app\">shown英寸

有另一种方式来获得的(主要)显示器的分辨率?

Is there another way to get the resolution of the (primary) display?

推荐答案

要改善其他的答案,甚至多一点,下面code也需要缩放因子,例如护理我为我的Windows显示200%(正常返回3200x1800)和300%的Lumia 930(192​​0×1080)。

To improve the other answers even a bit more, the following code also takes care of scaling factors, e.g. for my 200% for my Windows display (correctly returns 3200x1800) and 300% of the Lumia 930 (1920x1080).

var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
var size = new Size(bounds.Width*scaleFactor, bounds.Height*scaleFactor);

正如在其他的答案说,这只是根帧的大小被改变之前返回桌面上正确的尺寸。

As stated in the other answers, this only returns the correct size on Desktop before the size of root frame is changed.

这篇关于获取屏幕分辨率在Win10应用UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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