Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactivity.Behavior<T> vs attached properties

Tags:

wpf

behavior

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?

like image 790
Zim Avatar asked Feb 24 '10 16:02

Zim


1 Answers

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.

like image 60
Reed Copsey Avatar answered Sep 25 '22 04:09

Reed Copsey