Executing a command on Checkbox.Checked or Unchecked

Hosea146 picture Hosea146 · Apr 6, 2011 · Viewed 67.1k times · Source

I have a checkbox control on a window. I'd like to execute a command that will call a method in the associated view model. I'll also need the value of the checkbox as well. I cannot seem to find a way to associate a command with a checkbox. Has anyone done this?

Answer

Arseny picture Arseny · Apr 6, 2011
<CheckBox Content="CheckBox"
          Command="{Binding YourCommand}"
          CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}" />