MVVM Framework provides a powerful EventToCommand feature that allows delegating event processing logic to the ViewModel level. This example illustrates how to use this functionality to process DXGrid events.
The EventToCommand class provides the PassEventArgsToCommand option that allows passing the corresponding EventArgs as a command parameter. However, it is not good MVVM practice (even though it might be necessary in certain cases) to make a ViewModel aware of event arguments. It is better to extract necessary information from event arguments and then pass this information as a command parameter. To do this, use EventArgsConverter.
So, this example demonstrates the following cases:
1) How to invoke a command from a ViewModel when an event is raised. In this example, the built-in BestFitColumns command is invoked when the View's Loaded event is triggered.
2) How to invoke a command from a ViewModel when an event is raised and pass event arguments as a command parameter. This approach is used to delegate processing the ShowingEditor event to the ViewModel level.
3) How to invoke a command from a ViewModel when an event is raised, extract necessary information from event arguments using a Converter and then pass it as a parameter. The View's MouseDoubleClick and FocusedColumnChanged events are processed in this manner.
Note this approach can be used for other controls as well. This example also illustrates how to process a BarItem's ItemDoubleClick event in this manner.
To implement similar functionality in Silverlight, see T245878.