Windows Dev Center

ToggleButton.IsThreeState Property

Gets or sets whether the control supports two or three states.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public bool IsThreeState { get; set; }
<togglebutton IsThreeState="bool"/>

XAML Values

togglebutton

A literal ToggleButton, or a derived type such as CheckBox or RadioButton.

Property Value

Type: System.Boolean
true if the control supports three states; otherwise, false. The default is false.

Dependency property identifier field: IsThreeStateProperty

The IsChecked property can be set to null as a third state when IsThreeState is true.

The following example shows how to create a three-state ToggleButton control.


private void ThreeStateToggle_Click(object sender, RoutedEventArgs e)
{
    ThreeStateTextBlock.Text = "IsChecked: " + ThreeStateToggle.IsChecked.ToString();
}

private void TwoStateToggle_Click(object sender, RoutedEventArgs e)
{
    TwoStateTextBlock.Text = "IsChecked: " + TwoStateToggle.IsChecked.ToString();
}



<StackPanel x:Name="LayoutRoot" Background="Transparent" Margin="10">

    <ToggleButton Margin="5" Content="Three State" Name="ThreeStateToggle" Click="ThreeStateToggle_Click" IsThreeState="True"/>
    <TextBlock Name="ThreeStateTextBlock">IsChecked: </TextBlock>

    <ToggleButton Margin="5" Content="Two State" Name="TwoStateToggle" Click="TwoStateToggle_Click" IsThreeState="False" />
    <TextBlock Name="TwoStateTextBlock" >IsChecked: </TextBlock>
</StackPanel>


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft