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.

No Responses

  1. Retrieve the screen resolution of Windows Phone 7 using c# August 1, 2011 Reply

Leave a Reply


x

Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...