views:

49

answers:

1

Why do animation classes (like DoubleAnimation) require dependency properties? Dependency properties have a lot of overhead when compared to a simple property. Wouldn't passing in an object and property name and using to reflection to retrieve a setter delegate have made the animation classes more flexible and generally more usable? It would still have facilitated dependency properties, but would have the advantage of not requiring them.

+1  A: 

Because you can set them with SetValue and GetValue instead of having to do all the reflection stuff to find and set the property.

Bryant
If that were the case, the reflection stuff could just be wrapped into something easy to use like Animation.SetValue(object o, object value) or something similar. Dependency properties on the hand require a quite a bit more code than traditional properties, and forcing your object to inherit from a base class is limiting.
Mr Bell
Reflection isn't easy and it isn't cheap. It is much cheaper performance wise to force the use of dependency objects with a dependency base class.
Bryant