UWP 设备分辨率

Posted 法的空间

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UWP 设备分辨率相关的知识,希望对你有一定的参考价值。

之前看了下网上,分辨率都是用webview js拿或者全屏拿宽高,很有局限性。

研究一下。找到个完美的方法:

        public Size GetDeviceResolution()
        {
            Size resolution = Size.Empty;
            var rawPixelsPerViewPixel = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
            foreach (var item in PointerDevice.GetPointerDevices())
            {
                resolution.Width = item.ScreenRect.Width * rawPixelsPerViewPixel;
                resolution.Height = item.ScreenRect.Height * rawPixelsPerViewPixel;
                break;
            }
            return resolution;
        }

完美规避各种不方便

以上是关于UWP 设备分辨率的主要内容,如果未能解决你的问题,请参考以下文章