You can't access the checkbox this way, because there may be more than one of them, the name is valid only inside the DataTemplate
.
In the event handler, the sender
parameter should be the CheckBox
, you just have to cast it and then you can access the IsChecked
property. Another option would be to handle the Checked
and Uncheked
events.
But I think a better way would be to handle this in the bound class, not in code-behind of your GUI, separation of concerns and all that.