How to get Screen size of a windows phone 8 device?

旧巷老猫 提交于 2019-12-06 05:03:06

问题


I was searching for how can i get the Actual screen size of a windows phone 8 device , i've found this method but it work only with Devices With GDR3 update


回答1:


You can find the screen size by using

Application.Current.Host.Content.ActualWidth;

and

Application.Current.Host.Content.ActualHeight;

On my Windows phone 8s they return 480x800 which is the correct screen size.

Note that the values returned are relative to portrait mode, if you're using landscape you'll have to invert them.




回答2:


UPDATED : i've found this method

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) {
    }
}


来源:https://stackoverflow.com/questions/20298631/how-to-get-screen-size-of-a-windows-phone-8-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!