TRIGGERS & ACTIONS
Think of the following sentence:
When I press the button, the door opens.
This sentence includes
an
action
,
the opening off the door, and
a
trigger
that causes the action to happen,
pressing the button.
And that really is all an
Action
is:
An activity in the most general sense. We will have built-in
Actions
that do common things such as playing storyboards, setting properties, setting state and many more, but really, an
Action
can do anything someone decides to write.
Your imagination is the limit.
Just like
Actions
, Blend 3 will supply built-in
Triggers
, for example for common events.
And again,
Triggers
are extensible so the community can create new ones.
Here are a few
examples for possible
Triggers
:
TimerTrigger
fires when a timer expires.
You could have
triggers
that fire when a data base element changes. Or when the network connection on your machine goes down.
Again, only
your imagination is the limit.
BEHAVIORS
There are many bits of interactivity that cannot easily be encapsulated with
Triggers
and
Actions
.
For example, if you want to make something drag-able on a canvas, you need to deal with at least
three events:
You need to
-begin a drag when the mouse is pressed,
-update when the mouse is moved during a drag, and
-terminate the drag when the mouse is released.
Also, you need to preserve state. And this is exactly what behaviors allow you to do.
Behaviors
let you encapsulate
multiple related or dependent activities plus state in a single reusable unit.
Ref.: electric beach's blog[^]
For more have a look on following threads:
AN INTRODUCTION TO BEHAVIORS, TRIGGERS, AND ACTIONS[
^]
Difference between Behaviors and Action triggers in WPF MVVM[
^]