Click here to Skip to main content
15,118,063 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I'm trying to load an image from a path stored in a remote database onto a windows phone image control. For some reason, only the Content paths( "/dir/dir/filename.ext") seem to be working fine, but the resources, as in imgUri below, doesn't seem to load. Any idea why that is?


string imgUri = "\Applications\Data\7936FEAD-F146-4A5A-B628-DEE3A1F2D366\Data\PlatformData\PhotoChooser-bfd52ae9-0ed1-41ed-a523-8da7a9f01a25.jpg" ;


Uri uri = new Uri(imgUri, UriKind.Relative);
StreamResourceInfo resourceInfo = Application.GetResourceStream(uri);
BitmapImage bmp = new BitmapImage(uri);    
bmp.SetSource(resourceInfo.Stream) ;                 
usrImage.Source = bmp;

Why? If this is the resource embedded in your executable module, you already have a fully built strongly-typed image property, ready to use. Did you notice it? Do you use *.resx, or something else?
Member 9549287 8-Aug-13 15:06pm
The code actually works fine with images stored locally within the application, but when i use a photochooser task to select an image, then save the UriSource of the image into the database for later use, and try loading the image back to an image control in the application, it doesn't display anything. I'm using the standard .cs and .xaml

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900