Quantcast
Channel: Digitale Medien » Extension
Viewing all articles
Browse latest Browse all 6

Writing Behaviors for Silverlight 3 – Part 1

$
0
0

One of my favorite features of Silverlight 3 (and by extension Blend 3) is the new support for Behaviors. Behaviors are a way to allow designers to add functionality to XAML elements without code. In Blend 3, a couple of built-in behaviors are included (ShowMessageBox and ExecuteMethod). But of course I wanted to write my own behavior.

To start out you need to have a reference to a Blend assembly (for some reason its not part of the Silverlight SDK, at least at this point). The assembly is called Microsoft.Expression.Interactivity.dll and its located in

{ProgramFiles}Microsoft ExpressionBlend 3 PreviewLibrariesSilverlight

Once you have a reference to the Interactivity assembly, you can use one of the base classes to create a behavior.  There are several base classes of interest, but I will focus on three that are the most interesting:

  • Behavior<T>: Simple behaviors
  • TriggerAction<T>: Behavior tied to an event
  • TargettedTriggerAction<T>: TriggerAction that affects a separate object (e.g. the Target)

The class diagram looks like this:

Behavior Classes

more here


Viewing all articles
Browse latest Browse all 6

Trending Articles