如果我有这样的话:
<Button Command="{Binding TestCommand}">Test</Button>
<Button Command="{Binding TestCommand}">another Test</Button>
TestCommand是一个实现ICommand的命令对象。
是否可以在TestCommand的Execute功能中检测按下了哪两个按钮?
我认为这是可能的,如果我使用object参数,但我有其他参数要传递,所以这不是一个选项。
答案 0 :(得分:4)
尝试使用CommandParameters:
<Button Command="{Binding TestCommand}"
CommandParameter="{Param, ButtonUsed}">
Test</Button>