wpfvb.netmultibinding

WPF VB.NET IMultiValueConverter and "Conversion from type 'NamedObject' to type Double' is not valid"


Hello i have the following function in my 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

in the following line i get an exception "Conversion from type 'NamedObject' to type Double' is not valid"

If CDbl((values(1))) > 0 Then

so i wonder what might cause this exception, could it be failing to check for DBNULLS? note that the converter is working without the multi binding

or can it be that i am passing 2 values one is integer and one is double?


Solution

  • The NewItemPlaceholder in a CollectionView is a NamedObject, so maybe the ItemPlaceholder ends up being passed into your converter.