-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide
By :

Behaviors were introduced in Silverlight 3 and provide a new way of adding interactivity to UI elements without the use of code. Behaviors are reusable pieces of code that extend either a specific UI element (for example, TextBox
) or a whole type of elements (for example, FrameworkElement
). Behaviors are basically self-contained pieces of functionality that go along with the object they are attached to and react to its environment. Behaviors contain two important elements—Trigger
and Action. Trigger
elements are used to invoke an action. Take, for example the PlaySoundAction
behavior that comes bundled with Expression Blend 4. When adding this behavior, you need to set a trigger (when will the sound be played) such as MouseLeftButtonDown
or Loaded
, and then set the action itself, which is what sounds to play when the trigger triggers.
One important role of behaviors is controlling storyboard animations. Let's see how we can control animations without the use of code...
Change the font size
Change margin width
Change background colour