Search code examples
c#xamlwindows-8windows-runtimescreen-resolution

select images based on screen resolution


I am developing windows 8 metro app using XAML/C# .

I have added scaled versions of every images in the solution to support different screen resolutions .

Each image will have 2 additional copies in different sizes (100,140,180 %).

eg: sample_100.png,sample_140.png,sample_180.png

Now i want to know how can i choose the correct image based on screen resolution?

Us using a converter a good practice?


Solution

  • You don't need to do anything if you name them correctly. If you use names like

    • sample.scale-100.png
    • sample.scale-140.png
    • sample.scale-180.png

    then you can use them in XAML by just typing sample.png. It automatically picks up the one with the correct resource qualifier.

    Check this msdn article:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965324.aspx