Namespace IGSpreadsheet.Converters
Public Class ExcelBoolConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object
If TypeOf value Is ExcelDefaultableBoolean Then
Select Case DirectCast(value, ExcelDefaultableBoolean)
Case ExcelDefaultableBoolean.[True]
Return True
Case ExcelDefaultableBoolean.[False]
Return False
End Select
End If
Return Nothing
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object
If TypeOf value Is Boolean Then
If targetType = GetType(ExcelDefaultableBoolean) Then
Return If(CBool(value), ExcelDefaultableBoolean.[True], ExcelDefaultableBoolean.[False])
End If
End If
Return Nothing
End Function
End Class
End Namespace