A collection of Behaviors and Actions for use in Expression Blend


Download from http://expressionblend.codeplex.com/

Some of the triggers, actions, behaviors, effects:

Note: CallDataMethod, InvokeDataCommand – a wonderful way to trigger a method/command in your Silverlight MVVM ViewModel

  • PlayMedia– plays a media element
  • PauseMedia– pauses a media element
  • TogglePlayPauseMedia– toggles between play/pause on a media element
  • StopMedia– stops a media element
  • MouseGestureTrigger– triggers an action when the user makes a gesture on the element.

MouseGestureTrigger.png

  • MouseEventTrigger– allows more complex mouse triggers such as double-click or firing from handled events
  • StateChangedTrigger– triggers when the state is changed
  • CallDataMethod– An action which calls a method on the data context. Good for tying an event in your View to do something in the ViewModel for MVVM styled applications.
    An example of calling the ViewModel’s ViewModel1_ComboBox_SelectionChanged method when a ComboBox item is selected:
// View.xaml
// Make sure the DataContext is set to an instance of the ViewModel1 somewhere in xaml
<ComboBox>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="SelectionChanged">
            <si:CallDataMethod Method="ViewModel1_ComboBox_SelectionChanged" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
...
    
// ViewModel1.cs    
public void ViewModel1_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    ComboBoxItem item = e.AddedItems[0] as ComboBoxItem;
    var text = item.Content.ToString();
}
  • InvokeDataCommand-  An action which invokes a command on the data context. Another behavior for MVVM integration.

    Example of invoking the CheckOut command when a button is clicked:

    <i:EventTrigger EventName="Click">
          <si:InvokeDataCommand Command="{Binding ShoppingCart.CheckOutCommand}"/>
    </i:EventTrigger>
  • DataEventTrigger triggers when an event is raised on the data context. Useful for doing something such as playing a sound or animation when something happens on the data context
  • SetDataProperty– sets a property on the data context
  • DataStateBehavior– switches between two states depending on the value of a binding
  • FluidBindProperty– acts as a proxy for databound properties in order to animate the changing of the value
  • PropertyChangedTrigger– triggers when the value of the property changes, regardless of the new value
  • ClippingBehavior– Provides a rounded rectangular clipping that scales with the element. Useful since Silverlight and WPF clipping geometries don’t scale with objects
  • GoToNextState– Go to the next state in a VisualStateManager. Useful for quickly navigating between various states
  • GoToPreviousState– Go to the previous state in a VisualStateManager. Useful for quickly navigating between various states
  • SetProperty– Similar to ChangePropertyAction but allows incrementing as well as setting
  • ShowMessageBox– Displays a standard message box to the user
  • ListBoxAddOne– Action which duplicates a random item in the ItemsSource collection of a ListBox. Useful for SketchFlow prototypes where you want to show adding a new item
  • ListBoxRemoveOne– Action which removes a random item in the ItemsSource collection of a ListBox. Useful for SketchFlow prototypes to simulate removing an item.
  • ListBoxRemoveThisItem– Action for use inside of a ListBoxItem which will remove the item from the data collection of the owning ListBox.

Download from http://expressionblend.codeplex.com/

Advertisements

One thought on “A collection of Behaviors and Actions for use in Expression Blend

  1. Hi Vincent
    we are struggling with the import of setdataproperty from expression blend sample to silverlight 4.
    it seems that setdataproperty action doesn’t work properly.
    the binding inside the setdatapropert class is null and this looks weird.
    do you have any idea?

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