Trying to handle multi-resolution images in a Windows Phone
Universal App
I came across this article from Microsoft.
Unfortunately it only applies to Windows Phone 8 and Windows Phone Silverlight 8.1. When using the code samples they mention of:
private static bool IsWvga
{
get
{
return App.Current.Host.Content.ScaleFactor == 100;
}
}
In this case App.Current
doesn't have a Host property - Host presumably being the SilverlightHost property mentioned here.
Has anyone found a way to do the equivalent in an 8.1 Universal App
?
If you want to handle image scaling then it is handled by folder name in Windows Phone 8.1
Universal Apps
. Here is how:
To use these images in XAML you just give the file name and the OS does the rest.
<Image Grid.Row="1" Grid.Column="0" Source="wpimages/resolution.jpg" VerticalAlignment="Top" Width="100"/>
An additional method is simply to have multiple copies of the image at different scales and to name them in the same way as the folders i.e resolution.scale-100.jpg
, resolution.scale-240.jpg
. You still name the file the same in your XAML
.
I will share an article on that in the future.