MTR
MTR

Reputation: 1740

Is it possible to find the button that was pressed for a specific command?

If I have something like this:

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

TestCommand is a command object implementing ICommand.

Is it possible in the Execute function of TestCommand to detect which one of the two buttons was pressed?

I think this would be possible, if I use the object parameter, but I have other parameters to be passed, so this is not an option.

Upvotes: 0

Views: 54

Answers (1)

Parrish Husband
Parrish Husband

Reputation: 3178

Try using CommandParameters:

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

Upvotes: 4

Related Questions