I have collection of products from web service, I preview this product in Grid View, but I get the images of the products as Base64 strings. How can I convert it to images and bind it to the images in the Grid View?
Any piece of code that will help me in this issue.
This seem to work for me:
Note I don't await anything, img.SetSource should take care of delayed load.
Try something like this:
I haven't worked with metro, so I can't help with binding to grid.. Best regards.
In WPF/Metro/Silverlight, Image is a UI control. Its source is set to BitmapSource. BitmapSource is a data structure to hold image data.
Following is the code to retrieve BitmapImage from byte array.
Note that stream.AsRandomAccessStream is not available in API It is an extension method. I found it from response of IDWMaster to this SO question
Following is the code for extension method
Last 3 methods are not implemented
I have not tested but above should work in principal (may be after some refinement).
below is the method that binds a
Base64String
to anImage
controlconvert the string to byte[] as follows
pass the byte[] and the Image control to which you want to bind the Image to.