gray laptop computer showing html codes in shallow focus photography

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.

    1 Comment

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...