Partager via


ToggleButton.IsChecked Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets whether the ToggleButton is checked.

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

Syntax

'Declaration
<TypeConverterAttribute(GetType(NullableBoolConverter))> _
Public Property IsChecked As Nullable(Of Boolean)
[TypeConverterAttribute(typeof(NullableBoolConverter))]
public Nullable<bool> IsChecked { get; set; }
<togglebutton IsChecked="bool"/>
-or-
<togglebutton IsChecked="{x:Null}"/>

XAML Values

Property Value

Type: System.Nullable<Boolean>
true if the ToggleButton is checked; false if the ToggleButton is unchecked; otherwise nulla null reference (Nothing in Visual Basic). The default is false.

Remarks

Dependency property identifier field: IsCheckedProperty

A control that inherits from ToggleButton determines its behavior when this property is nulla null reference (Nothing in Visual Basic). In XAML, set the IsChecked property to the empty string ("") to display the indeterminate state. In code, you can set this property to nulla null reference (Nothing in Visual Basic).

CheckBox

When the IsThreeState property is set to true, a user can click a CheckBox to pick three possible states. The following table describes the three states of a CheckBox.

State of the CheckBox

Value of IsChecked

Checked

true

Unchecked

false

Indeterminate

nulla null reference (Nothing in Visual Basic)

If IsThreeState is false, you can still programmatically set this property to nulla null reference (Nothing in Visual Basic) to put the CheckBox in an indeterminate state, but the user cannot set the CheckBox to the indeterminate state through the user interface.

RadioButton

If you set this property to nulla null reference (Nothing in Visual Basic) on a RadioButton, the RadioButton is unchecked.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.