Skip to content

Instantly share code, notes, and snippets.

@minacle
Created March 10, 2014 00:50
Show Gist options
  • Save minacle/9457561 to your computer and use it in GitHub Desktop.
Save minacle/9457561 to your computer and use it in GitHub Desktop.
Public NotInheritable Class MultiplexConverter
Implements System.Windows.Data.IValueConverter
Private _Converters As New System.Collections.ObjectModel.Collection(Of System.Windows.Data.IValueConverter)
<System.ComponentModel.BindableAttribute(True)>
Public ReadOnly Property Items As System.Collections.ObjectModel.Collection(Of System.Windows.Data.IValueConverter)
Get
Return _Converters
End Get
End Property
Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim ConvertedValue = value
For Each Converter In _Converters
ConvertedValue = Converter.Convert(ConvertedValue, targetType, parameter, culture)
Next
Return ConvertedValue
End Function
Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
Dim ConvertedValue = value
For Each Converter In _Converters.Reverse
ConvertedValue = Converter.ConvertBack(ConvertedValue, targetType, parameter, culture)
Next
Return ConvertedValue
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment