在Windows Phone 8.1 XAML中获取设备屏幕分辨率

在Windows Phone 8中,我可以使用DeviceExtendedPropertiesApplication.Current.Host.Content.ScaleFactor获取屏幕分辨率。 这些都不适用于Windows Phone 8.1 XAML。

我找不到如何在Windows Phone 8.1 XAML中获得屏幕分辨率的方法,有没有办法?

使用WinRT API时,可以使用Windows.UI.Xaml.Window.Current.Bounds (高度和宽度)检索屏幕分辨率。

您需要将这些值乘以比例因子以获得真实分辨率。 您可以通过调用DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel来检索比例因子DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel

 var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; Debug.WriteLine("The current resolution is {0}x{1}", Window.Current.Bounds.Width * scaleFactor, Window.Current.Bounds.Height * scaleFactor); 

您可以使用Window和DisplayInformation获得有关分辨率的所有信息

 var bounds = Window.Current.Bounds; var displayInfo = DisplayInformation.GetForCurrentView();