My Windows Store app/Metro/Win RT app downloads image from server on to some local folder. I need to bind Image control to the downloaded image at runtime.
The problem is that image doesn’t show up unless I add it as a binary resource to the project.
My downloaded images are stored in ProjectFolder/Data/Media. Now, here is how I bind image source to image control.
<Image x:Name="WriterImage" Stretch="None" Source="{Binding Path=PersonData.Photo.MediaImageSource"></Image>
public ImageSource MediaImageSource
{
// Here _MediaUrl gets a value: ms-appx:///Data/Media/Writer1.jpg
BitmapImage source = new BitmapImage(new Uri(_MediaUrl));
}
This works only if I add Writer1.jpg as a resource to the project. If I remove it from the project, it doesn’t show up.
Note that there are different URL schemes that your application can access:
ms-appx:///is a read-only location, and refers to files that are included (compiled) with your application, such as resources.ms-appdata:///local/refers to local read-write storage for your application. If you are downloading files, my guess is that you should use this URL scheme.For your example above, I would try using the following URL:
ms-appdata:///local/Data/Media/Writer1.jpgSee the following for more info about URL (URI) schemes: http://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx