Iris Classon
Iris Classon - In Love with Code

WinRT/Metro App Q n’ A: How do I get the screen resolution and scale?

.

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]

Comments

Leave a comment below, or by email.
FacilisDK
5/12/2013 10:41:13 AM
You just saved my day! (again)
Thank you so much for that snippet! All I could find was way-to-advanced samples. 
Peter Foster
1/5/2014 11:33:21 PM
Another one of your gems! Thanks! 


Last modified on 2012-07-17

comments powered by Disqus