title: Check if ImageSource is empty
body: <p>I'm using <code>Binding</code> to <code>Image.SourceProperty</code> from <code>byte[]</code> variable. At <code>IValueConverter</code> I check if <code>value.Length &gt; 0</code>, if yes then I set source from it's value. Then I need to know, if it was set, so I can show or hide clear button. <code>Image.Source</code> always is not null. How can know, if it was set from <code>byte[]</code> array?
  My code:</p>
  
  <pre><code>var bnd = new Binding
  {
      Mode = BindingMode.TwoWay,
      Path = new PropertyPath("DataPath.Value"),
      Converter = new ByteToImageConverter()
  };
  myImage.SetBinding(Image.SourceProperty, bnd);
  
  public class ByteToImageConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          var val = value as byte[];
          var bmp = new BitmapImage();
          if (val.Length &gt; 0) {
              bmp.SetSource(new MemoryStream(val));
          }
          return bmp;
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          if (value == null) {
              return new byte[0];
          }
          var ms = new MemoryStream();
          var bmp = new WriteableBitmap(value as BitmapSource);
          bmp.SaveJpeg(ms, 150, 200, 0, 100);
          return ms.ToArray();
      }
  }
  </code></pre>
  
  <p>Now I need code to check, if image source property is set:</p>
  
  <pre><code>// myImage.Source always != null even if there was no bmp.SetSource() call
  var str = myImage.Source != null ? "Image is set" : "Image is empty";
  </code></pre>