title: Read image from URL save it in isolated storage and read and binding to a image source
body: <p>I'm saving an image from URL link to isolated storage and later I need to binding it to an image.</p>
  
  <p>This is the code where I get and save the image:<br>
  (the path value and the value is a class attribute) </p>
  
  <pre><code>private void saveImage(string name)
  {
          path = name;
  
          string uri = "http://sherutnetphpapi.cloudapp.net/mini_logos/" + path;
          WebClient m_webClient = new WebClient();
          imageUri = new Uri(uri, UriKind.Relative);
          m_webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_ImageOpenReadCompleted);
          m_webClient.OpenReadAsync(imageUri);
  }
  
  void webClient_ImageOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
  {
          using (IsolatedStorageFile myIsf = IsolatedStorageFile.GetUserStoreForApplication())
          {
              if (myIsf.FileExists(path))
              {
                  myIsf.DeleteFile(path);
              }
  
              IsolatedStorageFileStream fileStream = myIsf.CreateFile(path);
  
              StreamResourceInfo sri = null;
              sri = Application.GetResourceStream(imageUri);
  
              BitmapImage bitmap = new BitmapImage();
              bitmap.SetSource(sri.Stream);
              WriteableBitmap wb = new WriteableBitmap(bitmap);
  
              // Encode WriteableBitmap object to a JPEG stream.
              System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
              wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
              fileStream.Close();
          }
  }
  </code></pre>
  
  <p>In another class I read the image and binding it to an image source:</p>
  
  <pre><code>public class CompanyItem
  {
      public String companyIcon { get; set; } //save the file name in the isolated storge
      public String companyName { get; set; }
  
      [IgnoreDataMember]
      public BitmapImage ReadImageFromStorage 
      {
          get
          {
              BitmapImage image = new BitmapImage();
              IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
              string isoFileName = this.companyIcon;
              var stream = isoStore.OpenFile(isoFileName, System.IO.FileMode.Open);
              image.SetSource(stream);
              return image;
          }
      }
  </code></pre>
  
  <p>The xaml code is:</p>
  
  <pre><code>&lt;Image Height="63" HorizontalAlignment="Left" Margin="392,7,0,0" Name="imgConpamyIcon" Stretch="Fill" VerticalAlignment="Top" Width="70" CacheMode="BitmapCache" Source="{Binding ReadImageFromStorage}" /&gt;
  </code></pre>
  
  <p>The image is in a listBox within a listBox</p>
  
  <p>Please help me .... It drives me crazy</p>