我将 Image 的 Source 属性绑定到一个字符串。此字符串可能为空,在这种情况下我不想显示图像。但是,我在调试输出中得到以下信息:
System.Windows.Data 错误:23:无法使用默认转换将“<null>”从类型“<null>”转换为“en-AU”文化类型的“System.Windows.Media.ImageSource”;考虑使用 Binding 的 Converter 属性。NotSupportedException:'System.NotSupportedException: ImageSourceConverter 无法从 (null) 转换。在 System.ComponentModel.TypeConverter.GetConvertFromException(对象值)在 System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext 上下文,CultureInfo 文化,对象值)在 MS.Internal.Data.DefaultValueConverter.ConvertHelper(对象 o,类型 destinationType,DependencyObject targetElement, CultureInfo 文化, 布尔 isForward)'
我宁愿不显示它,因为它只是噪音 - 有什么方法可以抑制它?