# BooleanConverter Class

> The BooleanConverter class provides a way to convert a value to a boolean value. The converter returns true when the specified parameter is the string representation of the value. This is useful with data binding to place a checkmark in menus or to check or uncheck a toggle button. The class can be used in XAML as a static resource to automatically convert bound property values. Supported types are: System.Enum, int, int?, bool?, char and char?.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 16.0
- **Namespace:** `TXTextControl.WPF`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.WPF.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.WPF.dll` from the setup
- **Implements:** `System.Windows.Data.IValueConverter`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl.WPF > BooleanConverter Class
- **795 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/llms-full.txt

---

### Description

The BooleanConverter class provides a way to convert a value to a boolean value. The converter returns true when the specified parameter is the string representation of the value. This is useful with data binding to place a checkmark in menus or to check or uncheck a toggle button. The class can be used in XAML as a static resource to automatically convert bound property values. Supported types are: System.Enum, int, int?, bool?, char and char?.

### Syntax

```csharp
public class BooleanConverter : IValueConverter
```

```vbnet
Public Class BooleanConverter
    Implements IValueConverter
```

### Examples

The following XAML example shows how to bind radio buttons to the [InputFormat.NumberedListFormat](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/numberedlistformat-property/llms-full.txt) property using the BooleanConverter class and the [InputFormat.NumberFormats](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/numberformats-property/llms-full.txt) property.

```plaintext
…
xmlns:tx="clr-namespace:TXTextControl.WPF;assembly=TXTextControl.WPF"
…
<Window.Resources>
    <tx:BooleanConverter x:Key="boolConv" />
</Window.Resources>
…
<RadioButton
    Content="{Binding ElementName=textControl1, Path=InputFormat.NumberFormats[0]}"
    GroupName="numberFormat"
    IsChecked="{Binding
        ElementName=textControl1,
        Path=InputFormat.NumberedListFormat,
        Converter={StaticResource boolConv},
        ConverterParameter=ArabicNumbers}" />
<RadioButton
    Content="{Binding ElementName=textControl1, Path=InputFormat.NumberFormats[1]}"
    GroupName="numberFormat"
    IsChecked="{Binding
        ElementName=textControl1,
        Path=InputFormat.NumberedListFormat,
        Converter={StaticResource boolConv},
        ConverterParameter=Letters}" />
…
```

The following example creates a Boolean Converter instance for a document-processing operation. The created object is then available to the surrounding document workflow.

```csharp
TXTextControl.WPF.BooleanConverter booleanConverter = new();
Console.WriteLine("Boolean Converter is ready for use.");
```

```vbnet
Dim booleanConverter As New TXTextControl.WPF.BooleanConverter()
Console.WriteLine("Boolean Converter is ready for use.")
```

---

## In This Section

- [BooleanConverter.Convert Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/convert-method/llms-full.txt): Converts a value to a boolean. True is returned, if the specified parameter is the string representation of value.
- [BooleanConverter.ConvertBack Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/convertback-method/llms-full.txt): Converts a boolean to a value of the type specified through the targetType parameter.

---

## Nearby

- **Previous:** [BookmarkDialog.DialogItem Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/bookmarkdialog/dialogitem-enumeration/llms-full.txt)
- **Next:** [BooleanConverter.Convert Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/convert-method/llms-full.txt)
