Interface IValueConverter
Interface for ValueConverter object
public interface IValueConverter
Remarks
When implementing this interface it is a good practice to decorate your implementation with a ValueConversionAttribute attribute to indicate to development tools between what data types your converter can convert.
[ValueConversion(typeof(Employee), typeof(Brush))]
class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Dev) return Brushes.Beige;
if (value is Employee) return Brushes.Salmon;
return Brushes.Yellow;
}
}
Methods
- Convert(object, Type, object, CultureInfo)
Convert a value. Called when moving a value from source to target.
- ConvertBack(object, Type, object, CultureInfo)
Convert back a value. Called when moving a value from target to source. This should implement the inverse of Convert.