How to avoid EventArgs or any of its derivatives in the view model?

Topics: Questions
Jul 17, 2012 at 5:30 PM

Hello Geert,

I do not want to pass EventArgs or any derivatives of Eventargs into any of my view model methods. I don't want my viewmodel to depend upon various derivatives of Eventargs.

What is the correct approach to this situation?

Is there a way to send only the properties I want from the event args to the view model when using an EventToCommand?

It just seems like something basic that I can't find out how to handle.

Thank you,

Adriana

Coordinator
Jul 18, 2012 at 7:38 AM

The only way is to subscribe to the event in the code-behind and pass the values to the VM manually. 

What we might want to implement is automatic eventargs injection for a DTO object. Then you create your own DTO for eventargs which will be used in the command. However, I think you will just "move" this "design issue" to another location in your software.

What is wrong with the eventargs in your VM?