

You can use ms-appx to load any arbitrary file from your app package. = new BitmapImage(new Uri("ms-appx:///Assets/Images/logo.png")) And here’s how you refer to the same image resource in imperative code. Notice that you use the ms-appx URI scheme because you're referring to a file that comes from your app's package. Here’s how you use that name in XAML markup. If you name folders and/or files as in any of the examples in the previous section, then you have a single image resource and its name (as an absolute path) is /Assets/Images/logo.png. The name-or identifier-of an image resource is its path and file name with any and all qualifiers removed. Reference an image or other asset from XAML markup and code \Assets\Images\contrast-standard\theme-light \Assets\Images\contrast-standard\theme-dark Next is an example of how you can provide variants of an image resource-named /Assets/Images/logo.png-for different settings of display scale, theme, and high contrast. For purposes of illustration, these two variants are equivalent to the two above. That would be a better strategy if you have several asset files per qualifier. You can use qualifiers in folder names instead of file names. So, these two variants are equivalent (they both provide an image at scale 100, or scale factor 1). The default value for the scale qualifier is scale-100.

Qualify an image resource for scale, theme, and contrast Some common qualifiers for images are scale, theme, contrast, and targetsize. For background on how to use qualifiers in the names of your image resource files, see Tailor your resources for language, scale, and other qualifiers. You can also think of the image as an asset, and the file that contains it as an asset file and you can find these kinds of resource files in your project's \Assets folder. By using qualifiers in your images' file names, and optionally dynamically loading them with the help of a ResourceContext, you can cause the most appropriate image file to be loaded that best matches the user's runtime settings for display scale, theme, high contrast, language, and other contexts.Īn image resource is contained in an image resource file. They can also appear in your app package manifest source file (the Package.appxmanifest file)-for example, as the value for App Icon on the Visual Assets tab of the Visual Studio Manifest Designer-or on your tiles and toasts. These images can be referenced from imperative code or from XAML markup, for example as the Source property of an Image. Your app can load image resource files (or other asset files) tailored for display scale factor, theme, high contrast, and other runtime contexts.
