4

我正在寻找如何获得 windows phone 8 设备的实际屏幕尺寸,我找到了这种方法,但它仅适用于具有 GDR3 更新的设备

4

2 回答 2

12

您可以通过使用找到屏幕尺寸

Application.Current.Host.Content.ActualWidth;

Application.Current.Host.Content.ActualHeight;

在我的 Windows phone 8s 上,它们返回 480x800,这是正确的屏幕尺寸。

请注意,返回的值与纵向模式相关,如果您使用横向模式,则必须反转它们。

于 2014-03-17T12:11:49.693 回答
8

更新: 我找到了这个方法

private void getScreenInfo() 
{
    double dpix = -1.01;
    double screensize = -1.01;
    double dpiy = -1.01;
    Size res;
    try {
        dpix = (double)DeviceExtendedProperties.GetValue("RawDpiX");
        dpiy = (double)DeviceExtendedProperties.GetValue("RawDpiY");
        res = (Size)DeviceExtendedProperties.GetValue("PhysicalScreenResolution");
        screensize = Math.Sqrt(Math.Pow(res.Width / dpix, 2) + Math.Pow(res.Height / dpiy, 2));
    }
    catch (Exception e) {
    }
}
于 2013-11-30T09:30:31.323 回答