Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 499
Ahmed Ali Avatar asked Dec 01 '22 02:12

Ahmed Ali


2 Answers

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.

like image 96
Fabio Marcolini Avatar answered Dec 24 '22 07:12

Fabio Marcolini


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) {
    }
}
like image 45
Ahmed Ali Avatar answered Dec 24 '22 07:12

Ahmed Ali