在 Windows Phone 8 中,我可以使用 DeviceExtendedProperties
或 Application.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
var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
Debug.WriteLine("The current resolution is {0}x{1}", Window.Current.Bounds.Width * scaleFactor, Window.Current.Bounds.Height * scaleFactor);
关于c# - 在 Windows Phone 8.1 XAML 中获取设备屏幕分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24142802/