是否可以找到按下特定命令的按钮?

时间:2013-03-22 11:15:59

标签: c# xaml icommand

如果我有这样的话:

 <Button Command="{Binding TestCommand}">Test</Button>
 <Button Command="{Binding TestCommand}">another Test</Button>

TestCommand是一个实现ICommand的命令对象。

是否可以在TestCommand的Execute功能中检测按下了哪两个按钮?

我认为这是可能的,如果我使用object参数,但我有其他参数要传递,所以这不是一个选项。

1 个答案:

答案 0 :(得分:4)

尝试使用CommandParameters:

<Button Command="{Binding TestCommand}" 
    CommandParameter="{Param, ButtonUsed}">
       Test</Button>