Represents a value and multi-value converter that provides if-else functionality for Binding
and MultiBinding
objects.
- Inheritance:
- object object
Remarks
This converter expects the following source values to be specified:
- Condition - A bool value indicating whether the true or false value should be returned.
-
TrueValue - An object that is returned when the Condition is
true
. This can be omitted if the FalseValue parameter is also omitted, in which case the value of theTrueValue
property will be used. -
FalseValue - An object that is returned when the Condition is
false
. This can be omitted, in which case the value of theFalseValue
property will be used.
Examples
Constructors
ConditionalConverter()
Initializes an instance of the class.
Properties
ConditionValue
Gets or sets the optional value to use for the conditional test.
Property Value
- object:
The optional value to use for the conditional test.
FalseValue
Gets or sets the value returned when the conditional test is false
.
Property Value
- object:
The value returned when the conditional test is
false
.
TrueValue
Gets or sets the value returned when the conditional test is true
.
Property Value
- object:
The value returned when the conditional test is
true
.
Methods
Convert(object, Type, object, CultureInfo)
Converts a value.
Parameter | Type | Description |
---|---|---|
value | object | The value produced by the binding source. |
targetType | Type | The type of the binding target property. |
parameter | object | The converter parameter to use. |
culture | Culture |
The culture to use in the converter. |
Returns
- object:
A converted value. If the method returns null, the valid null value is used.
Convert(object[], Type, object, CultureInfo)
Returns either the second or third source value, based on the first source value.
Parameter | Type | Description |
---|---|---|
values | object[] | The array of values that the source bindings in the Multi |
targetType | Type | The type of the binding target property. |
parameter | object | The converter parameter to use. |
culture | Culture |
The culture to use in the converter. |
Returns
- object:
The second source value, if the first source value equals
true
; otherwise the third source value.
Remarks
See Conditional
ConvertBack(object, Type, object, CultureInfo)
Converts a value.
Parameter | Type | Description |
---|---|---|
value | object | The value that is produced by the binding target. |
targetType | Type | The type to convert to. |
parameter | object | The converter parameter to use. |
culture | Culture |
The culture to use in the converter. |
Returns
- object:
A converted value. If the method returns null, the valid null value is used.
ConvertBack(object, Type[], object, CultureInfo)
This method always returns null
and should not be used.
Parameter | Type | Description |
---|---|---|
value | object | Not used. |
targetTypes | Type[] | Not used. |
parameter | object | Not used. |
culture | Culture |
Not used. |
Returns
- object[]:
null
.