title: How to add Checked and Unchecked events in the DataGridCheckBoxColumn?
body: <p>I'm working on a C# WPF project and I'm searching for a trick to add Uncheck and Check events to the datagridCheckboxColumn, I have already found many solutions but I'm haven't got what I need exactly.</p>
  <p>My object is to colorize every checked row with Gray and to colorize every unchecked row by the user with white ( the default color of the datagrid).</p>
  <p>The event of the checked row worked perfectly and the row was colored when I checked the datagridCheckboxColumn.</p>
  <p>I'm searching for a solution for the unchecked event.</p>
  <p><strong>XAML Code</strong></p>
  <pre><code>&lt;DataGridCheckBoxColumn Header=&quot;Choose&quot; x:Name=&quot;choose&quot;&gt;
                      &lt;DataGridCheckBoxColumn.CellStyle&gt;
                          &lt;Style TargetType=&quot;DataGridCell&quot; BasedOn=&quot;{StaticResource {x:Type DataGridCell}}&quot;&gt;
                              &lt;EventSetter Event=&quot;CheckBox.Checked&quot; Handler=&quot;OnChecked&quot;/&gt;
                             
                          &lt;/Style&gt;
                          
                      &lt;/DataGridCheckBoxColumn.CellStyle&gt;
                  &lt;/DataGridCheckBoxColumn&gt;  
  </code></pre>
  <p><strong>C# Code</strong></p>
  <pre><code>
   private void OnChecked(object sender, RoutedEventArgs e)
          {
              for (int i = 0; i &lt; datagridView.Items.Count; i++)
              {
                  DataGridRow row = (DataGridRow)datagridView.ItemContainerGenerator.ContainerFromIndex(i);
                  CheckBox ch = (CheckBox)datagridView.Columns[0].GetCellContent(row);
                  bool ischecked = (bool)ch.IsChecked;
  
                  if (ischecked)
                  {
                      row.Background = Brushes.Gray;
  
                  }
                  
              }
          }
  
  </code></pre>