XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<CheckBox Content="CheckBox" Height="16" HorizontalAlignment="Left" Margin="10,10,0,0" Name="checkBox1" VerticalAlignment="Top" Checked="checkBox1_Checked" Unchecked="checkBox1_Unchecked" />
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="12,32,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
</Window>
C# code behind:
private void checkBox1_Checked(object sender, RoutedEventArgs e)
{MessageBox.Show("checkBox1 Checked");
}
private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
{
MessageBox.Show("checkBox1 UnChecked");
}
private void button1_Click(object sender, RoutedEventArgs e)
{
if (checkBox1.IsChecked == true)
MessageBox.Show("checkBox1 Checked");
else
MessageBox.Show("checkBox1 UnChecked");
}
Runtime: