I ran into a problem and I will be grateful to the experts for their help here. I am trying to get screen resolution in order to use appropriate layouts / images based on phone types.
My project type is WP7. Whenever I run the code on different WP7 and WP8 devices, I get the same resolution every time (800 X 480). Expected Behavior - I get a different resolution based on the type of device, for example. WVGA = 800 x 480, WXGA = 1280 x 768, 720p = 1280 x 720.
All the 3 code snippets below gave me the same resolution of 800 X 480, which was not expected.
Application.Current.RootVisual.RenderSize.Height + " x " + Application.Current.RootVisual.RenderSize.Width;
(App.Current.RootVisual as FrameworkElement).ActualHeight + " x " + (App.Current.RootVisual as FrameworkElement).ActualWidth;
App.Current.Host.Content.ActualHeight + " x " + App.Current.Host.Content.ActualWidth;
The MSDN article talks about how to do this in WP8, but keep in mind that I want the code to work on a WP7 device as well.
source
share