User Tools

Site Tools


technical_notes:public:wpf-how-to-create-behavior

Parent

WPF - How to create a behavior ?

You can use this template :

public class TemplateBehavior : Behavior<Control>
{
        #region Behavior
	protected override void OnAttached()
	{            
		base.OnAttached();
		// Bind to event on AssociatedObject
	}
 
	protected override void OnDetaching()
	{
		base.OnDetaching();
	}
        #endregion
 
}

To declare it in WPF, use the following code :

<border>
	<e:Interaction.Behaviors>
		<behaviors:TemplateBehavior/>
	</e:Interaction.Behaviors>
</border>

If the package e is missing, declare in the header :

 ... xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

Ressources

technical_notes/public/wpf-how-to-create-behavior.txt · Last modified: 2014/01/21 14:35 by Fabien Arcellier