title: Bind Image Source in WPF to a Url
body: <p>I having been browsing around different posts trying to figure out what is wrong with my issue. Basically I have a Image tag on my user control, and the Source I would like to bind to a url. However this does not work. I have tried using a ValueConverter that returns <code>BitmapImage(new Uri((string)value));</code>
  but this does not work. The only thing I have been able to get is that you cannot bind to a url and that you have to download the image you want to bind. I do not want to download all images I seacrch. Is there a work around to achieving this task with out having to download the image locally. I thought the ValueConverter method would have been the best by return a BitmapImage. Please help?</p>
  
  <pre><code>public class MyViewModel
  {
      private string _posterUrl;
          public string PosterUrl
          {
              get
              {
                  //Get Image Url, this is an example and will be retrieved from somewhere else.
                  _posterUrl = "http://www.eurobuzz.org/wp-content/uploads/2012/08/logo.jpg";
                  return _posterUrl;    
              }
              set 
              { 
                  _posterUrl = value;
                  NofityPropertyChanged(p =&gt; p.PosterUrl);
              }
          }
  }
  </code></pre>
  
  <p>This is my ValueConverter:</p>
  
  <pre><code>public class BitmapImageConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          if(value is string)
              return new BitmapImage(new Uri((string)value, UriKind.RelativeOrAbsolute));
  
          if(value is Uri)
              return new BitmapImage((Uri)value);
  
          throw new NotSupportedException();
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          throw new NotSupportedException();
      }
  }
  </code></pre>
  
  <p>This is my XAML:</p>
  
  <pre><code>&lt;Image Source="{Binding PosterUrl, Converter={StaticResource bitmapImageConverter}}" Width="100" Height="100" /&gt;
  </code></pre>
  
  <p>So this is binding to the PosterUrl property that contains the imageurl and this is converted to a bitmapimage. Any ideas?</p>