Retrieve the screen resolution of Windows Phone 7 using c#

The Current Windows Phone 7 devices provides the screen resolution of 480 X 800 pixels . Microsoft might introduce another resolution (320×480 ) .

It is easier to find this resolution via the WP7 SDK.

You can retrieve this screen resolution from the Windows Phone via the Current.Host.Content defined in the Application Class of System.Windows namespace .

This includes the properties to retrieve the actual height and actual width which gives 800 and 480 respectively.

 

using System.Windows;
public void GetScreenResolution()

{

     string ScreenWidth = Application.Current.Host.Content.ActualWidth.ToString();

     string ScreenHeight = Application.Current.Host.Content.ActualHeight.ToString();

     MessageBox.Show(ScreenWidth + "*" + ScreenHeight);

}

 

The Windows Phone Emulator uses the resolution 800 x 480. And hence when the above example function is used to test on the emulator, you should see the below.

 

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Responses

  1. Pingback: Retrieve the screen resolution of Windows Phone 7 using c#

Leave a Reply