title: WPF multiple checkbox check/uncheck
body: <p>I have 4 checkboxes one check all and the other three are subcheckboxes. I wanted to check all three subcheckboxes when I check check all and when I deselect one check box the main checkbox check all will be unchecked only. </p>
  
  <pre><code>&lt;Window x:Class="checkboxWPF.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"&gt;
  
    &lt;Grid Name="grdOne"&gt;
      &lt;CheckBox Content="Check"
                Checked="checkBox1_Checked"
                Unchecked="checkBox1_Unchecked"
                Height="16"
                HorizontalAlignment="Left"
                Margin="39,23,0,0"
                Name="checkBox1"
                VerticalAlignment="Top"&gt;
      &lt;/CheckBox&gt;
      &lt;CheckBox Content="One"
                Unchecked="checkBox2_Unchecked"
                IsChecked="{Binding Path=Ischecked, ElementName=checkBox1, Mode=TwoWay}"
                Height="16"
                HorizontalAlignment="Left"
                Margin="117,67,0,0"
                Name="checkBox2"
                VerticalAlignment="Top" /&gt;
      &lt;CheckBox Content="Two"
                Unchecked="checkBox3_Unchecked"
                IsChecked="{Binding Path=Ischecked, ElementName=checkBox1, Mode=TwoWay}"
                Height="16"
                HorizontalAlignment="Left"
                Margin="118,103,0,0"
                Name="checkBox3"
                VerticalAlignment="Top" /&gt;
      &lt;CheckBox Content="Three"
                IsChecked="{Binding Path=Ischecked, ElementName=checkBox1, Mode=TwoWay}"
                Height="16"
                HorizontalAlignment="Left"
                Margin="117,145,0,0"
                Name="checkBox4"
                VerticalAlignment="Top" /&gt;
      &lt;CheckBox Content="Four"
                IsChecked="{Binding Path=Ischecked, ElementName=checkBox1, Mode=TwoWay}"
                Height="16"
                HorizontalAlignment="Left"
                Margin="118,190,0,0"
                Name="checkBox5"
                VerticalAlignment="Top" /&gt;
    &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  
  
  <pre><code> public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
          }
  
          private void checkBox1_Checked(object sender, RoutedEventArgs e)
          {
              if (checkBox1.IsChecked == true)
              {
                  checkBox2.IsChecked = true;
                  checkBox3.IsChecked = true;
              }
          }
  
          private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
          {
              //if (checkBox1.IsChecked == false)
              //{
              //    checkBox2.IsChecked = false;
              //    checkBox3.IsChecked = false;
              //}
          }
  
          private void checkBox2_Unchecked(object sender, RoutedEventArgs e)
          {
              if (checkBox2.IsChecked == false)
              {
                  checkBox1.IsChecked = false;
              }
          }
  
          private void checkBox3_Unchecked(object sender, RoutedEventArgs e)
          {
              if (checkBox3.IsChecked == false)
              {
                  checkBox1.IsChecked = false;
              }
          }
      }
  </code></pre>