This is a mirror of official site: http://jasper-net.blogspot.com/

Silverlight 4: Introduction to Behaviors

| Sunday, March 20, 2011
In this article, I will introduce you to Behaviors in Silverlight. We will also create a small demo of the ‘MouseDragElementBehavior’ behavior using Expression Blend 4. So let’s get started.

We will first create a Silverlight project using ‘Microsoft Expression Blend 4.0’. Click on Start > Microsoft Expression > Microsoft Expression Blend 4 as shown below:
Create a new project and give it a name ‘BehaviorTesting’ as shown below:
Now let’s start with changing the background color of the layout. From the Objects and TimeLine window, choose ‘LayoutRoot’
Now from the property Window, change the following properties:

1) Background color – Black.
2) Width – 600.
3) Height – 500.

Now right click ‘LayoutRoot’ from ‘Objects and Timeline’ window and click on change Layout Type to ‘Canvas’.

Now let’s do a quick overview of the out-of-box ‘Behaviors’ in Silverlight 4.0. Shown below is a list of behaviors :

Call Method Action.
Change Property Action.
Control Storyboard Action.
Data State.
Fluid Move.
Fluid Move Set Tag Behavior.
Go To State Action.
Hyperlink Action.
Invoke Command Action.
Mouse Drag Element Behavior.
Play Sound Action.
Remove Element Action.
Set Data Store Value Action.
These behaviors are available out-of-the-box in Silverlight 4.0. These behaviors are available within the DLL – Microsoft.Expression.Interactions.dll. Now, let’s see what is a Behavior and how effectively we can use them in our Silverlight Applications using the behaviors listed above

What is Behavior?

Behaviour is a new way of interactivity without writing code, specially written by developers and used by designers in Microsoft Expression Blend 3.0/4.0. Behaviors makes interactivity much simpler for the designers. Developers can write their own custom behaviors which can be reused on different Silverlight, MVVM applications etc.

controlstoryboardaction0317.png

Read more: .net curry

Posted via email from Jasper-net

0 comments: