C# WPF错误-在何处查找源/解决方案
我对WPF很陌生。我创建了一个从web服务获取数据的应用程序。数据由字符串、日期、数字和图像组成 应用程序运行没有崩溃,但我认为一切都很好。我的数据也显示得很好。但是,我在输出窗口中看到以下内容:C# WPF错误-在何处查找源/解决方案,c#,wpf,C#,Wpf,我对WPF很陌生。我创建了一个从web服务获取数据的应用程序。数据由字符串、日期、数字和图像组成 应用程序运行没有崩溃,但我认为一切都很好。我的数据也显示得很好。但是,我在输出窗口中看到以下内容: System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.ImageSource' for 'en-US' culture w
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)'
什么可能导致此错误?从何处着手解决此问题
对不起,我知道这个问题有点含糊,我没有提供代码,因为我不知道提供什么,如果能全部提供就太多了。按照错误消息第一行中的数据进行操作: 无法从类型转换为类型“System.Windows.Media.ImageSource” 这意味着在您的XAML某处绑定了一个期望接收ImageSource的属性——通常,这意味着一个。但是,不是ImageSource的实例,而是将其设置为null
您可能不会在可视化布局中注意到它,因为它只是没有出现,但您应该检查图像绑定并查找它。您是否调试并检查了错误出现的时间点和时间点?请检查尝试显示图像的代码。ImageSource应该是非null的。您可以共享XAML中绑定了标记的部分吗?只需查看一下