Expression Blend 4: Behaviors


Behaviors: Introducing the concept of Behavior with Blend in WPF which benefit from full designer support, and thus providing a much higher level of accessibility to developers and designers. Behaviors allow designers to create production-quality interactivity without writing code. They work in WPF and Silverlight. Designers can use behaviors right on the Blend art board – they can be applied to elements with drag and drop, and many have configuration options available through the property inspector. They are not just a prototyping tool that is impossible to use in a production scenario.

Here I am going to illustrate the use of 2 behaviors of Expression Blend:
  1. MouseDragElementBehavior.
  2. RemoveElementAction.
  • Open a new project in Microsoft Expression Blend and draw a text block on your Artboard.

    Behaviors1.gif

  • Write down some text in to it with font size "36":

    Behaviors2.gif

  • Change the background of the textblock to gradientbrush and fill it according to yourself, also apply gradientbrush to the text so that your textblock should be like this:

    Behaviors3.gif

  • Now apply the MouseDragElementBehavior which you will find in the AssetsLiabrary, click on the behavior and select MouseDragElementBehavior, Drag it and Drop on the Textblock: 

    Behaviors4.gif

    Note: It will be seen in your object and timeline pane.

    Behaviors5.gif

  • Run your application and use drag and drop from your Mouse.

    Behaviors6.gif

  • Remove the MouseDragElementBehavior and again go to AssetsLiabrary and select RemoveElementAction, Drag and Drop the Behavior to the textBlock in the same way as you have done for the first one.

    Behaviors7.gif

  • Now again run the application and you will see that on a running application when you click on the textblock your textblock will be removed from the window:

    Behaviors8.gif

erver'>