问题描述
在的Windows Phone 8我可以使用屏幕分辨率 DeviceExtendedProperties
或 Application.Current.Host.Content.ScaleFactor
。这一切都在工作的Windows Phone 8.1的XAML。
In Windows Phone 8 I can get the screen resolution using DeviceExtendedProperties
or Application.Current.Host.Content.ScaleFactor
. None of this works in Windows Phone 8.1 XAML.
我无法找到一个方法如何让Windows Phone的8.1 XAML屏幕分辨率,有没有办法?
I could not find a way how to get the screen resolution in Windows Phone 8.1 XAML, is there a way?
推荐答案
在使用WinRT的API,可以检索与 Windows.UI.Xaml.Window.Current.Bounds $屏幕分辨率C $ C>(高度和宽度)。
When using the WinRT API, you can retrieve the screen resolution with Windows.UI.Xaml.Window.Current.Bounds
(Height and Width).
您需要通过比例系数乘以这些值来得到真正的解决。你可以通过调用 DisplayInformation.GetForCurrentView()获取比例因子。RawPixelsPerViewPixel
You need to multiply those values by the scale factor to get the real resolution. You can retrieve the scale factor by calling 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);
这篇关于得到的Windows Phone 8.1设备XAML屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!