I have a .NET Framework WPF Silverlight app which I am converting across to .NET Core Blazor WebAssembly. The existing app heavily uses binding converters (that implement System.Windows.Data.IValueConverter) throughout the UI codebase.
The <telerik:Rad* controls make use of these converters. Is there an equivalent to this for the Telerik Blazor controls?
N.B. Some of the converters are used in two-way binding.
Some examples of these existing converters:
Imports System.Windows.Data
Public Class DecimalZeroBlankConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
If value Is Nothing Then
Return Nothing
End If
If value = 0 Then
Return Nothing
End If
Dim dec As Decimal = value
Return dec.ToString("###,###,##0.00")
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class
Imports System.Windows.Data
Public Class PercentageConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
If value Is Nothing Then
Return 0
End If
Return value * 100
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
If value Is Nothing Then
Return 0
End If
If String.IsNullOrEmpty(value) Then
Return 0
End If
Return value / 100
End Function
End Class
Imports System.Windows.Data
Public Class YesNoVisibilityConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
If value Is Nothing Then
Return Visibility.Collapsed
End If
If value = "Y" Then
Return Visibility.Visible
Else
Return Visibility.Collapsed
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class
Imports System.Windows.Data
Public Class BooleanFontWeightConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
If value Then
Return FontWeights.Bold
Else
Return FontWeights.Normal
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class