Toggle button

Toggle button used to change the state.

xaml


<StackPanel>
<ToggleButton x:Name="tbtnGender" Checked="tbtnGender_GenderChanged" Unchecked="tbtnGender_GenderChanged" IsThreeState="True" Content="Gender: "></ToggleButton>
<TextBlock x:Name="tblGender"></TextBlock>
</StackPanel>

c#


private void tbtnGender_GenderChanged(object sender, RoutedEventArgs e)
{
this.SetGenderText();
}
private void SetGenderText()
{
switch (this.tbtnGender.IsChecked)
{
case null:
this.tblGender.Text = "Not specified";
break;
case true:
this.tblGender.Text = "Male";
break;
case false:
this.tblGender.Text = "Female";
break;
}
}
Next Recommended Reading Flat Button Styles in silverlight