您好,我的 IMultiValueConverter 中有以下功能
Public Function Convert(ByVal values() As Object, _
ByVal targetType As System.Type, _
ByVal parameter As Object, _
ByVal culture As System.Globalization.CultureInfo) As Object Implements IMultiValueConverter.Convert
If Not IsDBNull(values(0).ToString) And AndAlso Not IsDBNull(values(1).ToString) Then
If CDbl((values(1))) > 0 Then
Select Case CInt(Fix(values(0)))
Case 1
Return New LinearGradientBrush(Color.FromArgb(My.Settings.r1rowcolor.A, My.Settings.r1rowcolor.R, My.Settings.r1rowcolor.G, My.Settings.r1rowcolor.B), Color.FromArgb(My.Settings.r1rowendcolor.A, My.Settings.r1rowendcolor.R, My.Settings.r1rowendcolor.G, My.Settings.r1rowendcolor.B), My.Settings.r1angle)
Case 2
Return New LinearGradientBrush(Color.FromArgb(My.Settings.r2rowcolor.A, My.Settings.r2rowcolor.R, My.Settings.r2rowcolor.G, My.Settings.r2rowcolor.B), Color.FromArgb(My.Settings.r2rowendcolor.A, My.Settings.r2rowendcolor.R, My.Settings.r2rowendcolor.G, My.Settings.r2rowendcolor.B), My.Settings.r2angle)
Case 3
Return New LinearGradientBrush(Color.FromArgb(My.Settings.r3rowcolor.A, My.Settings.r3rowcolor.R, My.Settings.r3rowcolor.G, My.Settings.r3rowcolor.B), Color.FromArgb(My.Settings.r3rowendcolor.A, My.Settings.r3rowendcolor.R, My.Settings.r3rowendcolor.G, My.Settings.r3rowendcolor.B), My.Settings.r3angle)
Case Is > 3
Return New LinearGradientBrush(Color.FromArgb(My.Settings.rm3rowcolor.A, My.Settings.rm3rowcolor.R, My.Settings.rm3rowcolor.G, My.Settings.rm3rowcolor.B), Color.FromArgb(My.Settings.rm3rowendcolor.A, My.Settings.rm3rowendcolor.R, My.Settings.rm3rowendcolor.G, My.Settings.rm3rowendcolor.B), My.Settings.r4angle)
End Select
ElseIf CDbl((values(1))) < 0 Then
Return New LinearGradientBrush(Color.FromArgb(My.Settings.minpricesprice.A, My.Settings.minpricesprice.R, My.Settings.minpricesprice.G, My.Settings.minpricesprice.B), Color.FromArgb(My.Settings.minpricesprice.A, My.Settings.minpricesprice.R, My.Settings.minpricesprice.G, My.Settings.rm3rowendcolor.B), My.Settings.minpricespriceangle)
End If
End If
End Function
在以下行中我得到一个异常“从类型'NamedObject'到类型Double'的转换无效”
If CDbl((values(1))) > 0 Then
所以我想知道是什么导致了这个异常,它可能无法检查 DBNULLS 吗?请注意,转换器在没有多重绑定的情况下工作
还是我传递了 2 个值,一个是整数,一个是双精度值?