wpfmvvmcheckboxcommand

Executing a command on Checkbox.Checked or Unchecked


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?


Solution

  • <CheckBox Content="CheckBox"
              Command="{Binding YourCommand}"
              CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}" />