Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 35736

How to determine screen resolution on Windows Phone

$
0
0

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 - 480x800 or 800x480 (15:9 ratio)
WXGA - 768x1280 or 1280x768 (15:9 ratio)
720p - 720x1280 or 1280x720 (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


Viewing all articles
Browse latest Browse all 35736

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>