This documentation is archived and is not being maintained.

RadioButton Class

Updated: April 2009

Represents a button that can be selected, but not cleared, by a user. The IsChecked property of a RadioButton can be set by clicking it, but it can only be cleared programmatically.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public class RadioButton : ToggleButton

A RadioButton has two states: true or false.

Content Model: RadioButton is a ContentControl. Its content property is Content. For more information on the content model for RadioButton, see Controls Content Model Overview.

The RadioButton is a control that is usually used as an item in a group of RadioButton controls. However, it is possible to create a single RadioButton. Whether a RadioButton is selected is determined by the state of its IsChecked property.

When a RadioButton is selected, it cannot be cleared by clicking it. When RadioButton elements are grouped, the buttons are mutually exclusive. A user can select only one item at a time within a RadioButton group. You can group RadioButton controls by placing them inside a parent or by setting the GroupName property on each RadioButton.

Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.

The following example shows how to create RadioButton controls, group them inside a container, and handle the Checked event.

  <RadioButton Name="rb1" Checked="WriteText2">Yes</RadioButton>
  <RadioButton Name="rb2" Checked="WriteText2">No</RadioButton>
  <RadioButton Name="rb3" Checked="WriteText2">No opinion</RadioButton>
void WriteText2(object sender, RoutedEventArgs e)
    RadioButton li = (sender as RadioButton);
    txtb.Text = "You clicked " + li.Content.ToString() + ".";

The following code sample creates two separate RadioButton groups: colorgrp and numgrp. The user can choose one RadioButton in each group.

  <RadioButton GroupName="colorgrp">Red</RadioButton>
  <RadioButton GroupName="colorgrp">Blue</RadioButton>
  <RadioButton GroupName="numgrp">1</RadioButton>
  <RadioButton GroupName="numgrp">2</RadioButton>


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0




April 2009

Added an event handler implementation to the first example.

Customer feedback.

February 2009

Described how default styles change dependency properties.

Customer feedback.