Loading File Variations Manually

If your app loads external files (such as from your own Web server), then you cannot take advantage of automatic resource qualifier support. However, you can certainly mimic it in C# by inspecting the aspects of the current environment you care about. The following Windows Store C# code demonstrates how you might fetch different files based on the current automatic scaling and contrast mode:

void LoadImage(Image image, string filename){  // Either "Scale100Percent", "Scale140Percent", or "Scale180Percent":  string scale = DisplayProperties .ResolutionScale.ToString();  // Getting the current user theme is a bit more onerous:  AccessibilitySettings settings = new AccessibilitySettings ...

Get XAML 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.