0

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 ???}" /> 

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.