Simple Mvvm EventToCommand

Dec 11, 2012 at 10:02 PM

Hi Tony,

I've read through all your documentation, and I know that generally you prefer the CallMethodAction approach, using bound properties to get any require information. 

In browsing through the Discussion Board / Issue Tracker, it appear that you have implemented an EventToCommand feature in Simple Mvvm, however, I can't seem to figure out how to use it.

I'm working with a WPF test app to familiarize myself with Simple Mvvm, and for the life of me, I can't seem to find an EventToCommand anywhere.

1. Is there in fact an EventToCommand in SimpleMvvm?

2. If there is, what exactly do I have to do to get to it (what xmls do I need to import, etc)?

Dec 11, 2012 at 10:16 PM
Event to Command is only implemented for Windows Phone apps, because CallMethodAction isn't supported on that platform. If you are responding to button click, commands are available; otherwise, you'd need to use CallMathodAction.
Dec 11, 2012 at 10:24 PM

Gotcha, thanks!

Dec 12, 2012 at 12:00 PM

Actually, I will say that one thing lacking from CallMethodAction that the EventToCommand approach offers is the ability to pass the EventArgs to the ViewModel.  Do you have any clean solution for dealing with this?  I'm thinking along the lines of handling a drag/drop scenario for example where the EvenArgs are pretty essential to be able to do much.

Dec 14, 2012 at 12:42 PM

One of the drawbacks of CallMethodAction is that the method defined on the ViewModel cannot accept parameters.  Usually the way to get around this is to define a property on the ViewModel and use that to pass information into the method called via the CallMethodAction.  I'm not sure exactly how you would go about doing this in the scenario you're describing, but if you come up with a solution, please post it here.  Much thanks.