The standard way to do this with WPF is to use a pattern called MVVM (Google this pattern, you'll find lots of examples there on how this all hangs together). Now, let's assume that you have a class called MyData that looks like this:
public class MyData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool checkedItem;
public bool CheckedItem
{
get { return checkedItem; }
set
{
if (checkedItem == value) return;
checkedItem = value;
OnChanged("CheckedItem");
}
}
private void OnChanged(string property)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(property));
}
}
}
Now, because you have a data grid, you are obviously wanting to display many rows, so you create another class that manages the data:
public class ClassToBindTo
{
public ClassToBindTo()
{
MyDataCollection = new ObservableCollection<MyData>();
}
public ObservableCollection<MyData> MyDataCollection{ get; private set; }
public void PopulateData()
{
AddDummyData(true);
AddDummyData(true);
AddDummyData(false);
AddDummyData(true);
}
private void AddDummyData(bool checkItem)
{
MyDataCollection.Add(new MyData { CheckedItem = checkItem });
}
}
Finally, you hook your data grid up to use MyDataCollection as your ItemsSource (your DataContext would be ClassToBindTo in this example), and the check box would use this as the binding
"Checked={Binding CheckedItem}".
And that's it, your check box binds to the boolean value, and the boolean value gets checked/unchecked when the checkbox is clicked.