Behaviors, Actions, and Triggers (Compact 2013)

3/26/2014

Behaviors encapsulate interactions as reusable components that are applied to a UI element in a XAML for Windows Embedded application. A behavior consists of an action and a trigger. When the trigger occurs, the corresponding action occurs. Behaviors offer a way to connect code-behind functionality to different elements in the visual tree using XAML. This lets developers create encapsulated interactions that can be shared across many individual elements.

A behavior typically has the following properties (represented as attributes in XAML):

  • SourceName. The name of the source object that the behavior is applied to.
  • EventName. The event of the source object that will trigger the action.
  • TargetName. The name of the target object that will be affected by the action taken.
  • PropertyName. The name of the property on the target object that will be changed, if the action is to change or set a property.

Some behaviors support only a subset of these properties, or include other properties that pertain to their specific functionality.

Supported Behaviors

The following behaviors are supported in XAML for Windows Embedded:

  • ChangePropertyAction. Causes the specified property to change to a specified value.
  • ControlStoryboardAction. Causes a storyboard animation to play, pause, stop, resume, skip to the end, or toggle between play and pause.
  • GoToStateAction. Causes the source object to transition to a different visual state.
  • RemoveElementAction. Deletes an object from the visual tree.
  • MouseDragElementBehavior. Enables an object to be dragged around the screen.
  • FluidMoveBehavior. Animates a change in the position of an element.

You can use these behaviors in a Blend for Visual Studio project, and then convert the project by using Windows Embedded XAML Tools. The behaviors will continue to work as expected without any additional coding in your XAML for Windows Embedded project.

Note

The PlaySoundAction and HyperlinkAction behaviors are supported in Expression Blend but are not supported in XAML for Windows Embedded. For other Expression Blend features that are not supported in XAML for Windows Embedded, see Unsupported Controls and Features in Expression Blend.

In This Section

See Also

Concepts

Build an Interactive XAML Application