我正在将Image的Source属性绑定到字符串.此字符串可能为null,在这种情况下,我只是不想显示图像.但是,我在Debug输出中得到以下内容:
System.Windows.Data错误:23:无法将类型为"<null>"的"<null>"转换为使用默认转换为"en-AU"文化键入"System.Windows.Media.ImageSource"; 考虑使用Binding的Converter属性.NotSupportedException:'System.NotSupportedException:ImageSourceConverter无法转换(null).位于System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context,CultureInfo culture,Object value)的System.ComponentModel.TypeConverter.GetConvertFromException(Object value)at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o,Type destinationType,DependencyObject) targetElement,CultureInfo culture,Boolean isForward)'
我更喜欢这个没有显示,因为它只是噪音 - 是否有任何方法可以抑制它?
我有一个实体,其中包含TimeSpan
我想要保存在Azure表存储中的属性.当我尝试保存实体时,我收到错误:
无法转换为不支持的类型'TimeSpan'
有没有办法进行自动转换或其他方式支持TimeSpan
?
在ASP.Net Core中,可以使用命令将配置值注入到类中IOptions<T>
.
所以,如果我有以下appsettings.json
配置:
{
"CustomSection": {
"Foo": "Bar"
},
"RootUrl": "http://localhost:12345/"
}
Run Code Online (Sandbox Code Playgroud)
我可以注入IOptions<CustomSection>
我的构造函数(假设我已经定义了一个CustomSection
类)并读取Foo
属性.
如何将RootUrl
设置注入构造函数或不支持?