# Toggle Button

**RadToggleButton** inherits from the native **ToggleButton** control and implements the [ICommandSource](https://msdn.microsoft.com/en-us/library/system.windows.input.icommand\(v=vs.110\).aspx) interface. Because of the inheritance, it has all of the features of the native **ToggleButton** control. The **ICommandSource** implementation allows you to attach commands to the button, which will get executed when it gets clicked.

> tip You can see how to use ICommand with a button in the [Commands](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/commands) topic.

> caption Toggle button

![WPF RadButtons Toggle button](https://www.telerik.com/products/wpf/documentation/assets/90bfa8355b2cb0bf3eb3b7c66fdb3650/radbuttons-features-toggle-button-0.png)

## Defining RadToggleButton

You can instantiate **RadToggleButton** in both XAML and code as shown in Examples 1 and 2.

**Example 1: Defining a button in XAML**

```XAML
<telerik:RadToggleButton Content="Toggle Me!" />
```

**Example 2: Defining a button in code**

```C#
RadToggleButton radToggleButton = new RadToggleButton() { Content = "Toggle Me!" };
```

```VB.NET
Dim radToggleButton As New RadToggleButton() With { _
    .Content = "Toggle Me!" _
}
```

## Enable Three State Mode

To make **RadToggleButton** to go into a three state mode you can just set its **IsThreeState** property to **True**.

**Example 5: Enabling the three-state mode**

```XAML
<telerik:RadToggleButton IsThreeState="True" />
```

## Toggle Events

The button provides a set of events that are fired when you toggle it.

* **Checked**: This event is fired when the button is toggled on.
* **Unchecked**: This event is fired when the button is toggled off.
* **Activate**: This event is fired when the button is toggled on or off.

> tip As any other button, RadToggleButton exposes a **Click** event, too. Additionally, the control has **PreviewClick** event.

The toggle state of the button can be manually controlled via its **IsChecked** property.

Here is an example of handling the **Checked** event of a button.

**Example 3: Subscribing to the Checked event**

```XAML
<telerik:RadToggleButton Content="Toggle Me!" Checked="RadToggleButton_Checked" />
```

**Example 4: Defining a Checked event handler**

```C#
private void RadToggleButton_Checked(object sender, RoutedEventArgs e)
{
    //implement your logic here
}
```

```VB.NET
Private Sub RadToggleButton_Checked(sender As Object, e As RoutedEventArgs)
    'implement your logic here'
End Sub
```

## Customizing RadToggleButton

* **IsBackgroundVisible**: This property controls the visibility of the background and the border of the button when in normal state.

  > caption Toggle button with hidden background

  ![WPF RadButtons Toggle button with hidden background](https://www.telerik.com/products/wpf/documentation/assets/f14a1c054e062abd82a5da917e4e058e/radbuttons-features-toggle-button-1.png)

* **CornerRadius**: This property controls the corner radius of the button.

  > caption Toggle button with its CornerRadius set to 15

  ![WPF RadButtons Toggle button with its CornerRadius set to 15](https://www.telerik.com/products/wpf/documentation/assets/6a86728f593f849d621d45aa6f613ed2/radbuttons-features-toggle-button-2.png)

## See Also

* [Button](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/button)
* [Radio Button](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/radbutton-radio-button)
* [Commands](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/commands)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/events)
