2

I am very new to WPF. I create an app that gets data from a web service. Data consists of strings, dates, numbers and images.

The app runs (no crashing) however and I thought all is fine. My data is also displayed just fine. However, I see in the Output window following:

System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.ImageSource' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: ImageSourceConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'

What could cause this error? Where to start looking to fix this issue?

Sorry, I know the question is bit vague and I have not provided code because dont know what to provide, it would be to much to provide it all.

pixel
  • 9,653
  • 16
  • 82
  • 149

1 Answers1

4

Follow the data in the first line of the error message:

Cannot convert <null> from type <null> to type 'System.Windows.Media.ImageSource'

This means that in your XAML somewhere you're binding a property that expects to receive an ImageSource - usually, this means an <Image Source="{Binding ...}"/>. However, instead of an instance of an ImageSource, you're giving it null.

You might not notice it in the visual layout because it just doesn't appear, but you should go over your image bindings and look for it.

Avner Shahar-Kashtan
  • 14,492
  • 3
  • 37
  • 63