views:

226

answers:

1

I want to pass the Button Event Arguments as a CommandParameter on a WPF Button. What would be the syntax I should use?

<Button x:Name="btnMain" Command="viewmodel:ApplicationCommands.MyCommand"CommandParameter="{Binding ???}" /> 
+2  A: 

I assume you mean the EventArgs you'd get if you handled the Click event? In a word, you can't. Commands are commands, they're not events, so don't have the same EventArgs.

If you really want to get access to EventArgs (or something containing the same information) in your Command then you'll probably have to resort to using an Attached Behaviour - there is a sample one on CodePlex that handles mouse events (MouseEventTrigger.cs).

Before you do that though you might want to consider exactly what it is you're trying to achieve - if it isn't mouse event specific then you might be barking up the wrong tree.

Steven Robbins
Thanks Steven for pointing me in the right direction.
Ashish Ashu