Windows-10 UWP Binding Image url to Image source in ListView

Ganesh kudva picture Ganesh kudva · May 19, 2016 · Viewed 13.4k times · Source

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?

Answer

Konstantin picture Konstantin · May 19, 2016

If you are looking for XAML-based binding here is how:

<Image>
    <Image.Source>
        <BitmapImage UriSource="{Binding ImageSource}" />
    </Image.Source>
</Image>