Behaviors, Triggers and Actions snippets - Rudi Grobler
Saturday, June 27, 2009 9:38 AM rudi

Behaviors, Triggers and Actions snippets

I am fortunate to be presenting a session about Expression Blend at Tech-ed Africa 2009  this year. One of the topics I will be covering is how easy it is to create behaviours, triggers and actions using Microsoft.Expression.Interactivity.dll!

Behaviours, triggers and actions is well encapsulated but still require a small amount of repetitive code… I created 3 snippets to aid in creating them! Here is the default implementations created using the snippets:

Behavior

/// <summary>
/// 
/// </summary>
public class MyBehavior : Behavior<FrameworkElement>
{
    /// <summary>
    /// 
    /// </summary>
    protected override void OnAttached()
    {
        base.OnAttached();
    }

    /// <summary>
    /// 
    /// </summary>
    protected override void OnDetaching()
    {
        base.OnDetaching();
    }
}

Trigger

/// <summary>
/// 
/// </summary>
public class MyTrigger : TriggerBase<FrameworkElement>
{
    /// <summary>
    /// 
    /// </summary>
    protected override void OnAttached()
    {
        base.OnAttached();
    }

    /// <summary>
    /// 
    /// </summary>
    protected override void OnDetaching()
    {
        base.OnDetaching();
    }
}

Action

/// <summary>
/// 
/// </summary>
public class MyAction : TriggerAction<FrameworkElement>
{
    /// <summary>
    /// 
    /// </summary>
    protected override void OnAttached()
    {
        base.OnAttached();
    }

    /// <summary>
    /// 
    /// </summary>
    protected override void OnDetaching()
    {
        base.OnDetaching();
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="parameter"></param>
    protected override void Invoke(object parameter)
    {

    }
}

Download the snippets here

More Information

If you found this interesting or useful please kick it on DotNetKicks.com

Filed under: , , , ,

Comments

# Behaviors, Triggers

Saturday, June 27, 2009 9:42 AM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Dew Drop &#8211; Weekend Edition &#8211; June 27-28, 2009 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop &#8211; Weekend Edition &#8211; June 27-28, 2009 | Alvin Ashcraft's Morning Dew

# re: Behaviors, Triggers and Actions snippets

Monday, June 29, 2009 11:37 AM by Willie Roberts

Awesome on the Blend Session and belated congratulations on the MVP. Hope you enjoy Tech-Ed!