New to Telerik UI for .NET MAUIStart a free 30-day trial

Represents an IValueConverter that converts string values to boolean values. Returns true if the string is not null or empty, or if a parameter is provided and contains the string value.

Definition

Namespace:Telerik.Maui.Controls

Assembly:Telerik.Maui.Controls.dll

Syntax:

C#
public class StringToBoolConverter : IValueConverter

Inheritance: objectStringToBoolConverter

Implements: IValueConverter

Constructors

C#
public StringToBoolConverter()

Methods

Converts a string value to a boolean.

C#
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Parameters:valueobject

The string value to convert.

targetTypeType

The type to convert to (should be bool).

parameterobject

An optional parameter string to check if it contains the value.

cultureCultureInfo

The culture to use for the conversion.

Returns:

object

True if the parameter contains the value (case-insensitive), or if parameter is null and value is not null or empty; otherwise, false.

Converts a boolean value back to a string. This operation is not supported.

C#
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Parameters:valueobject

The boolean value to convert back.

targetTypeType

The type to convert back to.

parameterobject

An optional parameter (not used).

cultureCultureInfo

The culture to use for the conversion (not used).

Returns:

object

This method always throws a NotSupportedException.

Exceptions:

NotSupportedException

Always thrown as conversion back from bool to string is not supported.