I am porting my WinRT app to UWP. My app tries to display an image, the uri for which is received from an online query.
I am binding it to Image source like this in XAML
<Image Source="{Binding ImageSrc}" Stretch="UniformToFill" />
App cannot fetch image from this uri. It is only able to display images which are present in app container (Anything in /Assets/ folder)
The uri I receive from the online query is valid. I verified that by pasting the uri in browser. The browser is able to fetch & display the image from uri.
I read this post on Data Binding in WPF. It atleast says that the above binding would work if "ImageSrc is a string representation of a valid uri to an image". ImageSrc is valid uri in my case
Since the above thread is for WPF, I am not sure if that stands true even for UWP or not. Is there anything additional that I need to do in this case?
I can give you one alternative. You can set the Image source from the code behind file. The Url does not directly render using the "source" property of the Image tag. You have to convert the URL to a Bitmap Image first then set the source property to that Bitmap object
Try this,
Image.Source = new BitmapImage(
new Uri("http://yourdomain.com/image.jpg", UriKind.Absolute));
as seen on the question here Programmatically set the Source of an Image (XAML)
If you are looking for XAML-based binding here is how:
<Image>
<Image.Source>
<BitmapImage UriSource="{Binding ImageSource}" />
</Image.Source>
</Image>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With