TriggerAction driven command execution with zero code behind


image

The new Behavior-based trigger system (which works in Silverlight and WPF) opens the door for custom Trigger Actions. Now that we have custom Trigger Actions, we will be able to create an ExecuteCommandAction that allows you to invoke a Command from any trigger.

What’ll we be doing is creating an ExecuteCommandAction that we can trigger using any Blend trigger, this action will be bound to a ICommand exposed by the ViewModel.

In the current version of Silverlight standard behaviors don’t support Binding, there is a work around discussed earlier on this blog by PeteBlois using BindingListeners and exposing Bindings rather than ICommand.

public class ExecuteCommandAction : TriggerAction<FrameworkElement>

{

private readonly BindingListener commandListener;

private readonly BindingListener commandParameterListener;

Read more –> http://compiledexperience.com/blog/posts/Blendable-MVVM-Commands-and-Behaviors

And here –> http://azurecoding.net/blogs/brownie/archive/2009/04/06/blend-behaviors-ftw.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s