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 ???}" />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.