by
81 7
-2
4
87
0
Tagged
Specified
Refined
OpenSource

Published on:

FrameworkUWP
InputName0imageName
InputType0string
Languagecsharp
LicenseMIT_X11
MethodNameImageFromName
OutputTypeImage

UWP: Get an image from local resources

Build an Image object from local resources. The image should be stored as content in the Assets folder of the project.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4361252/UWP--Get-an-image-from-local-resources?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static Image ImageFromName(this string imageName) { if (imageName == null) return null; if (!imageName.StartsWith("ms-appx:///Assets/")) imageName = "ms-appx:///Assets/" + imageName; return new Image { Source = new BitmapImage(new Uri(imageName, UriKind.RelativeOrAbsolute)) }; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus