我意识到还有其他具有相同标题的问题,但是我尝试了所有这些解决方案均无济于事。我正在尝试使用我制作的转换器。我的另一个转换器工作正常,这个新转换器是前一个转换器的复制粘贴,名称已更改,返回值已更改。
XAML
xmlns:local="clr-namespace:ARC"
<local:DoublerConvert x:Key="DoubleConverter"/> 'Doesn't work
<local:ValueConverter x:Key="NegativeConverter"/> 'Works fine
代码
Public Class ValueConverter
Implements IValueConverter
Public Function ProvideValue(serviceProvider As System.IServiceProvider) As Object
Return Me
End Function
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Dim OldWidth As Integer = value
OldWidth = -OldWidth
Return OldWidth
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class
Public Class DoublerConvert
Implements IValueConverter
Public Function ProvideValue(serviceProvider As System.IServiceProvider) As Object
Return Me
End Function
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Dim OldWidth As Integer = value
Return 2 * OldWidth
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class