Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what are the diferences among Behaviours ,triggers, Action.


i have read many articalls about this but iam unable to understand what are basic differences among them . when should i go for those in silver light

Please help me any one
Posted

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900