ToggleButton.IsThreeState Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets whether the control supports two or three states.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<togglebutton IsThreeState="bool"/>
XAML Values
Property Value
Type: System.Booleantrue 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>
Show: