concept callmethodaction behavior in category silverlight

appears as: CallMethodAction behavior
Silverlight 4 in Action: Silverlight 4, MVVM, and WCF RIA Services

This is an excerpt from Manning's book Silverlight 4 in Action: Silverlight 4, MVVM, and WCF RIA Services.

In this section, we’ll look at two ways you can have elements in XAML invoke methods in the ViewModel. The first approach, ICommand, is the traditional way initially introduced in WPF and supported in most MVVM toolkits. The second, the CallMethodAction behavior, is a new approach introduced with Expression Blend 4.

Listing 16.16 shows how to use the CallMethodAction behavior to create the link between the More Vacation! button and the ViewModel method that implements that behavior.

Listing 16.16. Using the CallMethodAction behavior instead of the command

Despite the limitations (a potential performance hit due to use of reflection, and the inability to set the IsEnabled property automatically), the CallMethodAction behavior is a good low-code-overhead approach to wiring up method calls. And remember, unlike ICommand, the CallMethodAction is supported on just about any event on any control.