Sunday, October 18, 2009

Behaviors Library for WPF

In my previous post, Behaviors in WPF with Expression Blend 3, I explained some basics about behaviors with Expression Blend 3. So now, I decided to start working on a library that will combine (hopefully) lots of behaviors for everyday use. I started with several behaviors for Window objects.

Here is what the library contains for now:

  • WindowDragMoveBehavior – When attached to a window, this behavior allows the window to be moved with the mouse, but not just by dragging the title bar of the window, as is the default behavior, but by clicking on any point of the window, and then moving the mouse. This is useful when you have skinned apps and you don’t actually have the title bar.
  • AnimatedShowHideElementBehavior – Animates the showing or hiding of a framework element (works best for window elements now). Supports several types of animations:
      • Fade In
      • Fade Out
      • Zoom In
      • Zoom Out
      • Skew

Using the library is simple, just add a reference to the .dll file in your project and Expression Blend will start showing the new behaviors in the assets:


Then, just drag and drop the behavior to an element to start using it:


And you’ll see the settings of the behavior in Blend:


Of course, this library is very small now, and i promise that I will add more and more behaviors when I have the time. Any suggestions will be appreciated.

Download the behaviors library

You can download the behaviors library and a small demo project from this link.

No comments:

Post a Comment