Take the 2-minute tour ×

I'm trying to find some differences between these approaches. Is there any situation where behaviors are used and the same functionality could not be done with attached properties?

share|improve this question
add comment

4 Answers

up vote 25 down vote accepted

No. Behaviors are basically just a much nicer abstraction on top of attached properties.

By using Behavior<T>, you gain access to the AssociatedObject directly, as well as the ability to attach and detach the behavior, easily, at runtime.

You could do this with attached properties, but it would require adding a lot of extra plumbing.

share|improve this answer
+1. A very good description –  RichardOD May 14 '12 at 10:29
However, it becomes difficult to add them with a style. –  Stephen Drew Jul 8 '12 at 22:38
Actually there are a few things you can't do with attached properties... For example, it would be possible to add several instances of the same behavior, but you can only set an attached property once. OTOH, attached properties have a shorter syntax, and can be used in styles, which is difficult with behaviors. –  Thomas Levesque Jul 6 '13 at 2:01
@ThomasLevesque you can also define an Attached Property that adds Behaviors to a given UI element, and set that property in a Style.. haha =) –  HighCore Aug 30 '13 at 21:27
add comment

Behviors are based on attached properties. That means if you can't find specific behavior - you write your own, either based on behavoirs framework provided by Blend or by creating your own AP...

I always though that behaviors are great evidence of attached properties power. Just incredible what you can get with them.

share|improve this answer
add comment

I tend to use Behaviors to add functionality which makes visible changes. Whereas I use attached properties to add additional information to an object which is subsequently used by other objects.

E.g. Grid.Row makes a good attached property, as it's used by the Grid and not the target. On the other hand, AutoCorrect would make a good behaviour, as this will make visible changes on the object.

share|improve this answer
add comment

This is not the answer. But the best explanation I can find on this topic http://briannoyes.net/2012/12/20/attached-behaviors-vs-attached-properties-vs-blend-behaviors/

Brian Noyes in his articles clearly describes the differences between each of the concepts.

share|improve this answer
add comment

Your Answer


