Click or drag to resize

BinaryOperationConverter Class

Applies the Operation on the value and the converter parameter.

May also be used as IMultiValueConverter where both operands are specified using bindings.

Inheritance Hierarchy

Namespace:  TomsToolbox.Wpf.Converters
Assembly:  TomsToolbox.Wpf (in TomsToolbox.Wpf.dll)
Syntax
[ValueConversionAttribute(typeof(Object), typeof(Object))]
public class BinaryOperationConverter : ValueConverter, 
	IMultiValueConverter

Return Value

Type: 
If the conversions succeed, the result of the operation is returned. If any error occurs, the result is UnsetValue.

The BinaryOperationConverter type exposes the following members.

Constructors
  NameDescription
Public methodBinaryOperationConverter
Initializes a new instance of the BinaryOperationConverter class
Top
Properties
  NameDescription
Public propertyConvertBackErrorValue
Gets or sets the error value, which is returned whenever the value to convert back produces an error; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertBackNullValue
Gets or sets the null value, which is returned whenever the value to convert back is null; the default is null.
(Inherited from ValueConverter.)
Public propertyConvertBackUnsetValue
Gets or sets the unset value, which is returned whenever the value to convert back is UnsetValue; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertErrorValue
Gets or sets the error value, which is returned whenever the value to convert produces an error; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertNullValue
Gets or sets the null value, which is returned whenever the value to convert is null; the default is null.
(Inherited from ValueConverter.)
Public propertyConvertUnsetValue
Gets or sets the unset value, which is returned whenever the value to convert is UnsetValue; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyOperation
Gets or sets the operation the converter is performing.
Top
Methods
  NameDescription
Protected methodConvert(Object, Type, Object, CultureInfo)
Converts a value.
(Overrides ValueConverterConvert(Object, Type, Object, CultureInfo).)
Public methodConvert(Object, Type, Object, CultureInfo)
Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
Public methodConvertBack(Object, Type, Object, CultureInfo)
Converts a binding target value to the source binding values.
Protected methodConvertBack(Object, Type, Object, CultureInfo)
Converts a value.
(Inherited from ValueConverter.)
Public methodProvideValue
When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
(Inherited from ValueConverter.)
Top
Fields
  NameDescription
Public fieldStatic memberAddition
The default addition converter.
Public fieldStatic memberDivision
The default division converter.
Public fieldStatic memberEquality
The default equality converter.
Public fieldStatic memberGreaterThan
The default greater than converter.
Public fieldStatic memberGreaterThanOrEqual
The default greater than or equals converter.
Public fieldStatic memberInequality
The default inequality converter.
Public fieldStatic memberLessThan
The default less than converter.
Public fieldStatic memberLessThanOrEqual
The default less than or equals converter.
Public fieldStatic memberMultiply
The default multiplication converter.
Public fieldStatic memberSubtraction
The default subtraction converter.
Top
Extension Methods
  NameDescription
Public Extension MethodSafeCastT
Performs a cast from object to T, avoiding possible null violations if T is a value type.
(Defined by ObjectExtensions.)
Public Extension MethodTraceError
Traces an error for the specified converter.
(Defined by ValueConverterExtensions.)
Top
Remarks
Either

- both value and parameter must be convertible to a double

or

- value must have an explicit operator for the specified operation and parameter has a type converter matching the expected operator parameter.

If the value supports implicit or explicit casts, the operation is retried on all types that the original type can be casted to. This enables the converter to handle most operations on Vector, Size, Point, etc...

For Rect the Addition is mapped to Offset(Vector) and the Multiply is mapped to Transform(Matrix)

See Also