Loading File Variations Automatically

Fortunately, Windows exposes a simple yet powerful built-in scheme for handling automatic scaling for any image file packaged in your app. You can provide three separate variations, one for each possible scale. If you follow one of two naming conventions, then the Image element automatically uses the correct one for the current environment.

For example, if you set an Image’s Source to Assets/photo.jpg, then you can name the three variations of this file as follows to take advantage of this automatic support:

Assets/photo.scale-100.jpg

Assets/photo.scale-140.jpg

Assets/photo.scale-180.jpg

You don’t even need a file matching the original name used in your C# or XAML! For conditions when the app is scaled ...

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.