Advertisemen
Introduction:
There may be many cases ,in which you need to supply higher quality images that should be fit into current device screen resolutions and its makes nice attractions for app users. Fortunately windowsphone is very good at detecting screen resolutions.However previously in windowsphone 8.0,to determine screen resolutions we are using the "App.Current.Host.Content.ScaleFactor" .But now its not working in windowsphone 8.1,So this post is explained about what is the alternative way for detecting screen resolutions in windowsphone store 8.1.Building the sample:
- Make sure you’ve downloaded and installed the Windows Phone SDK. For more information, see Get the SDK.
- I assumes that you’re going to test your app on the Windows Phone emulator. If you want to test your app on a phone, you have to take some additional steps. For more info, see Register your Windows Phone device for development.
- This post assumes you’re using Microsoft Visual Studio Express 2013 for Windows.
Description:
Lets start to comparisons between wp8.0 vs wp8.1 while detecting the screen resolutions.
WindowsPhone 8.0:
in windowsphone 8,ScaleFactor is useful for determine screen resolutions.
string ScreenScaleFactor = App.Current.Host.Content.ScaleFactor.ToString();
if (App.Current.Host.Content.ScaleFactor == 100)
{
ScreenScaleFactor = "WVGA";
}
else if (App.Current.Host.Content.ScaleFactor == 160)
{
ScreenScaleFactor = "WXGA";
}
else if (App.Current.Host.Content.ScaleFactor == 150)
{
ScreenScaleFactor = "720p";
}
MessageBox.Show(ScreenScaleFactor);
WindowsPhone 8.1:
In wp8.1 the following no.of screen images available
So lets start to detect screen resolutions
Step1: Get the number of raw (physical) pixels for a current view
Step2: Get the current bounds
Step3: Finally multiply bounds 'width' and 'height' values individually with raw pixels
xaml" style="border-color: rgb(208, 210, 210); border-style: solid; border-width: 2px 1px; margin-bottom: 10px !important; padding: 10px; word-wrap: break-word !important;">var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
string currentresolution = Window.Current.Bounds.Width * scaleFactor + "*" + Window.Current.Bounds.Height * scaleFactor;
MessageDialog messageDialog = new MessageDialog(currentresolution);
await messageDialog.ShowAsync();
string currentresolution = Window.Current.Bounds.Width * scaleFactor + "*" + Window.Current.Bounds.Height * scaleFactor;
MessageDialog messageDialog = new MessageDialog(currentresolution);
await messageDialog.ShowAsync();
ScreenShots:
1)Emulator 8.1 WVGA 4 inch 520MB:2)Emulator 8.1 WXGA 4 inch:
Note: Please share your thoughts,what you think about this post,Is this post really helpful for you?otherwise it would be very happy ,if you have any thoughts for to implement this requirement in any another way?I always welcome if you drop comments on this post and it would be impressive.
Follow me always at @Subramanyam_B
Have a nice day by Subramanyam Raju :)
Advertisemen
Tidak ada komentar:
Posting Komentar