Class ValueConversionAttribute
This attribute allows the author of a IValueConverter to specify what source and target property types the ValueConverter is capable of converting. This meta data is useful for designer tools to help categorize and match ValueConverters.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class ValueConversionAttribute : Attribute
- Inheritance
-
ValueConversionAttribute
Remarks
Add this custom attribute to your IValueConverter class definition.
[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;
}
}
Constructors
- ValueConversionAttribute(Type, Type)
Creates a new ValueConversionAttribute to indicate between what types of a data binding source and target this ValueConverter can convert.
Properties
- ParameterType
The type of the optional ValueConverter Parameter object.
- SourceType
The expected source type this ValueConverter can handle.
- TargetType
The target type to which this ValueConverter can convert to.
- TypeId
Returns the unique identifier for this Attribute.
Methods
- GetHashCode()
Returns the hash code for this instance.