【发布时间】:2011-07-20 22:52:53
【问题描述】:
我将 Image 的 Source 属性绑定到一个字符串。此字符串可能为空,在这种情况下我不想显示图像。但是,我在调试输出中得到以下信息:
System.Windows.Data 错误:23:不能 将 '
' 从类型 ' ' 转换为 类型 'System.Windows.Media.ImageSource' 为 'en-AU' 文化默认 转换;考虑使用转换器 绑定的属性。 NotSupportedException:'System.NotSupportedException: ImageSourceConverter 无法转换 从(空)。在 System.ComponentModel.TypeConverter.GetConvertFromException(对象 值)在 System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext 上下文,CultureInfo 文化,对象 值)在 MS.Internal.Data.DefaultValueConverter.ConvertHelper(对象 o,类型destinationType, DependencyObject 目标元素, CultureInfo 文化,布尔值 isForward)'
如果这只是噪音,我宁愿不显示 - 有什么方法可以抑制它?
【问题讨论】:
-
我不太确定这只是噪音。在我的应用中,我认为它会导致一些性能问题(加载所有空图像时)。
-
是的,这肯定会导致性能问题。详情见我的回答。
标签: .net wpf image exception-handling ivalueconverter