Jul 172012
 
 July 17, 2012  Posted by at 9:42 am WinRT  Add comments

Following a discussion on the Metro/WinRT mailinglist I’ve decided to share a handy little code snippet. With different screen resolutions, aspect ratios and scaling you might need to display things differently, and maybe you would like to access the resolution and scale details in code/programmatically. Well, it’s actually quite easy:

[sourcecode language=”XML”]
//
double height = Windows.UI.Xaml.Window.Current.Bounds.Height;
double width = Windows.UI.Xaml.Window.Current.Bounds.Width;
ResolutionScale resolutionScale = DisplayProperties.ResolutionScale;
//
[/sourcecode]

  4 Responses to “WinRT/Metro App Q n’ A: How do I get the screen resolution and scale?”

  1. […] WinRT/Metro App Q n’ A: How do I get the screen resolution and scale? (Iris Classon) […]

  2. […] or column an element is in when reacting to a layout change. Let’s give it a try…”WinRT/Metro App Q n’ A: How do I get the screen resolution and scale? (Iris Classon)“Following a discussion on the Metro/WinRT mailinglist I’ve decided to […]

  3. You just saved my day! (again)
    Thank you so much for that snippet! All I could find was way-to-advanced samples.

  4. Another one of your gems! Thanks!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 11 + 7 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)