How to get the screen size of a Windows Phone 8 device?

I was looking for how I can get the actual screen size of a Windows Phone 8 device, I found this method, but it only works with devices with GDR3 update

+4
source share
2 answers

UPDATED: I 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) {
    }
}
+8
source

Screen size can be found using

Application.Current.Host.Content.ActualWidth;

and

Application.Current.Host.Content.ActualHeight;

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

Please note that the return values ​​refer to portrait mode; if you use landscape, you will have to invert them.

+12
source

All Articles