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

Igo*_*man 20 c# xaml windows-phone-8 windows-phone-8.1

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

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

Kev*_*sse 31

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

您需要将这些值乘以比例因子以获得真实的分辨率.您可以通过调用来检索比例因子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);
Run Code Online (Sandbox Code Playgroud)


yas*_*sen 10

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

var bounds = Window.Current.Bounds;
var displayInfo = DisplayInformation.GetForCurrentView();
Run Code Online (Sandbox Code Playgroud)