Hi habrayuzer!
After completing several projects on wp7, I was faced with an often arising task: storing images in isolated storage and then rendering these images. When viewing the thematic blogs and articles, I found nothing but the most direct and
simple resource-intensive way to do it. As it turns out - everybody does it! So let's talk about this method and about my little talk.
For storage of data on disk is used Isolated Storage. This class allows the developer to access the isolated directory on disk. This directory can be accessed by only one application and in it you can create a hierarchical structure for storing data. This is both good and bad - it’s not possible to share data between applications. But the image task is still as important. On the other hand, if this task is necessary for caching an image to work offline - you should think: after all, the system caches images on its own, perhaps in your application and there is no need to implement caching manually. So:
Method number 1 - the most "simple"
We save pictures in storage in any way you like. Now you need to use isolated storage to display the image. An image is read from the repository to the stream, after which the image from the stream enters the
BitmapImage and this object is assigned to the
Source property.
A simplified
converter that does the above steps:
')
public class IsoImageConverter : IValueConverter {
Well, and XAML:
<Image Source="{Binding ImagePath, Converter={StaticResource IsoImageCoverter}}"/>
This method is described everywhere as a way to display an image from an
ISNow method number 2 - the most non-trivial
Once I was given the task: to investigate the possibility of constructing offline maps using an existing component of maps. I downloaded images in
IS. I decided to try using method number 1. It didn't work. Having broken my head for several hours, I remembered how I once read somewhere about the fact that an emulator that is installed on a Windows machine can be unzipped and get the path to the application and files in the storage. Well, if there is a path and access along this path is possible only from the application - you can probably insert a link to the image in
Image and it will be displayed. So, what was done:
To begin with, the link to the image was captured in the debager while saving.

Path:
\ Applications \ Data \ AD105BA4-EC12-49E0-9077-B5D95DBA2FEE \ Data \ IsolatedStore \ test \ SplashScreenImage.jpgNow having the path to the picture, you can use it as a
Source for the image. But, as it turned out, it is necessary to use only absolute paths, therefore it is necessary to add the prefix
file: ///We are convinced that the picture is there and that it is not damaged:

and paste this code into XAML:
<Image Height="200" Width="200" Source="file:///Applications/Data/AD105BA4-EC12-49E0-9077-B5D95DBA2FEE/Data/IsolatedStore/test/SplashScreenImage.jpg"/>
And as a result:

With the map component did not work, but a valuable experience for myself made. As a result, a simpler way was found to display images from
IsolatedStorage .
PS: Pictures from the Shared folder in this way could not be pulled out.