Reputation: 938
I should get my Image's Uri but when I try to do it it is giving this error.
Image's UriSource is able to casting BitmapImage but BitmapImage's properties are throwing errors. How can I get image's source?
img0.Source = GetImageForIndex(0, names, file, path).ImgSource;
ImageListTemplate GetImageForIndex(int index, List<string> names, IsolatedStorageFile file, string path)
{
using (IsolatedStorageFileStream stream = file.OpenFile(path + names[index], FileMode.Open, FileAccess.Read))
{
BitmapImage tempImage = new BitmapImage();
tempImage.SetSource(stream);
imagePath = path + names[index];
return new ImageListTemplate() { ImgSource = tempImage };
}
}
ImgSource's Type is BitmapImage already.
Upvotes: 0
Views: 214
Reputation: 65586
You're not setting a URI source for your image, you're loading it from a stream of data instead.
The BitmapImage
can be populated from a stream or a URI. You can only read the UriSource if this was set, by creating the image from a URI.
Based on your code, if you want a reference back to the original data source when querying the SelectedItem
, I'd suggest storing that path/file information in the Tag
property. Alternatively add it as another property of the bound items datasource and query that.
Upvotes: 2