How to determine screen resolution on Windows Phone 8


This is a very common scenario most developers stumble across – they are building an app for Windows Phone and have to target all 3 screen resolutions available with Windows Phone 8.

The 3 screen resolutions for your reference are:

WVGA – 480×800 or 800×480 (15:9 ratio)
WXGA – 768×1280 or 1280×768 (15:9 ratio)
720p – 720×1280 or 1280×720 (16:9 ratio)

There may be many scenarios in which you would want to know the screen resolution of the device your app is running on, a popular one being that you want to show higher quality images for higher resolution devices. You can accomplish this very easily by checking for the ScaleFactor as follows:

  if(App.Current.Host.Content.ScaleFactor == 100)
  {
    // WVGA
  }
  else if (App.Current.Host.Content.ScaleFactor == 160)
  {
    // WXGA
  }
  else if (App.Current.Host.Content.ScaleFactor == 150)
  {
     // 720p
  }

More at http://paraswadehra.blogspot.com/2012/12/how-to-determine-screen-resolution-on.html


Paras Wadehra
Twitter: @ParasWadehra
FB Group: http://www.facebook.com/WindowsPhoneDeveloper

Comments (1)

  1. ando says:

    Hi Paras,

    It is not clear how one can use high quality images as all images are resized.

    So even using images 720p on device with 720p resolution – image will be stretched outside the screen.

    Can you explain how to use the exact resolution of device without automatic resizing.

    Thanks