在 Checkbox.Checked 或 Unchecked 上执行命令 [英] Executing a command on Checkbox.Checked or Unchecked
本文介绍了在 Checkbox.Checked 或 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?
推荐答案
<CheckBox Content="CheckBox"
Command="{Binding YourCommand}"
CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}" />
这篇关于在 Checkbox.Checked 或 Unchecked 上执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文