Class BooleanConverter
[ValueConversion(typeof(object), typeof(bool))]
public class BooleanConverter : IValueConverter
- Inheritance
-
BooleanConverter
- Implements
- Inherited Members
Remarks
If the source value is of type bool, then the value is passed through unchanged. If the source value is of type string, then the value is true if it is not an empty string. Otherwise, the value is true if the source is not null. NOTE: Does NOT convert strings like "True" and "False"; any non-empty string will yield true.
Properties
IsReversed
Gets or sets whether to reverse (i.e., apply a Boolean NOT to) the return value.
public bool IsReversed { get; set; }
Property Value
Methods
Convert(object, Type, object, CultureInfo)
Converts a value.
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Parameters
value
objectThe value produced by the binding source.
targetType
TypeThe type of the binding target property.
parameter
objectThe converter parameter to use.
culture
CultureInfoThe culture to use in the converter.
Returns
ConvertBack(object, Type, object, CultureInfo)
Converts a value.
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Parameters
value
objectThe value that is produced by the binding target.
targetType
TypeThe type to convert to.
parameter
objectThe converter parameter to use.
culture
CultureInfoThe culture to use in the converter.
Returns
ConvertObjectToBoolean(object)
Converts any object to a bool.
public static bool ConvertObjectToBoolean(object value)
Parameters
value
objectThe object to convert.
Returns
- bool
The object's boolean value (see the class remarks).
Remarks
NOTE: Does NOT convert strings like "True" and "False"; any non-empty string will yield true.