Toggle button is a sticky button, which have two states i.e. checked and Unchecked by default. It don’t have cancel behaviours of the button. Clicking this first time will set IsChecked property to true, and second time clicking will set IsChecked property to false.
The following XAML code will show two toggle buttons with IsChecked property true and false respectively. As the checkbox button, toggle button also have IsThreeState property means it have three states i.e. checked, unchecked and indeterminate.
When we want to use the third state, then the value of IsChecked will be {x:Null} and it will also look like false value. The above code will show the window with two toggle button like following image:
To use third property we have to set IsThreeState property to true. Now first click set the IsChecked to true, second will set null and third will set to false. It have individual event for all the three states:
The following XAML code will show two toggle buttons with IsChecked property true and false respectively. As the checkbox button, toggle button also have IsThreeState property means it have three states i.e. checked, unchecked and indeterminate.
<ToggleButton Margin="5" Height="20" Width="100" IsChecked="True"/>
<ToggleButton Margin="5" Height="20" Width="100" IsChecked="False"/>
<ToggleButton Margin="5" Height="20" Width="100" IsChecked="False"/>
When we want to use the third state, then the value of IsChecked will be {x:Null} and it will also look like false value. The above code will show the window with two toggle button like following image:
To use third property we have to set IsThreeState property to true. Now first click set the IsChecked to true, second will set null and third will set to false. It have individual event for all the three states:
private void ToggleButton_Checked(object sender, RoutedEventArgs e)
{
}
private void toggleButton_Unchecked(object sender, RoutedEventArgs e)
{
}
private void toggleButton_Indeterminate(object sender, RoutedEventArgs e)
{
}
{
}
private void toggleButton_Unchecked(object sender, RoutedEventArgs e)
{
}
private void toggleButton_Indeterminate(object sender, RoutedEventArgs e)
{
}
Tidak ada komentar:
Posting Komentar